Reset a Radio button inside a Radio group

try this : radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) { if (checkedId == R.id.radioButton){ //do something } else if(checkedId == R.id.radioButton2){ } else{ } }); xml layout <RadioGroup android:layout_width=”fill_parent” android:layout_height=”90dp” android:layout_below=”@+id/imageView” android:layout_marginTop=”58dp” android:weightSum=”1″ android:id=”@+id/radioGroup” android:layout_alignLeft=”@+id/textView2″ android:layout_alignStart=”@+id/textView2″ android:layout_alignRight=”@+id/textView3″ android:layout_alignEnd=”@+id/textView3″> <RadioButton android:layout_width=”wrap_content” android:layout_height=”55dp” android:text=”Male” android:id=”@+id/radioButton” android:layout_gravity=”center_horizontal” android:checked=”false” android:textSize=”25dp” /> <RadioButton android:layout_width=”wrap_content” android:layout_height=”wrap_content” … Read more

Download binary file from OKHTTP

For what it’s worth, I would recommend response.body().source() from okio (since OkHttp is already supporting it natively) in order to enjoy an easier way to manipulate a large quantity of data that can come when downloading a file. @Override public void onResponse(Call call, Response response) throws IOException { File downloadedFile = new File(context.getCacheDir(), filename); BufferedSink … Read more

Get Value of a Edit Text field

By using getText(): Button mButton; EditText mEdit; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mButton = (Button)findViewById(R.id.button); mEdit = (EditText)findViewById(R.id.edittext); mButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { Log.v(“EditText”, mEdit.getText().toString()); } }); }

Run an audio file instantly when clicking on the application button (Android)

1.you add button 2. public class Setting extends Activity implements OnClickListener{ private MediaPlayer Music; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_setting); Music = MediaPlayer.create(this, R.raw.musicname); findViewById(R.id.button).setOnClickListener(this); } public void onClick(View view) { if (view.getId() == R.id.button) { Music.start(); } } } only Preview 😀

Loading a WebView URL before splashscreen finishes

One way we can achieve this is by rather than opening a new activity for webview, In WelcomeActivity.java itself add webView and imageView to the layout and make webview to invisible or Gone. On open of WelcomeActivity initialize webView and set custom WebViewClient. Override onPageFinished() in your Custom webViewClient and in this method make webview … Read more

Services or intent services to send location updates every 5 sec to server endlessly?

If you want to achieve this using service public class MyService extends Service { @Nullable @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { ScheduledExecutorService scheduleTaskExecutor = Executors.newScheduledThreadPool(5); // This schedule a runnable task every x unit of time scheduleTaskExecutor.scheduleAtFixedRate(new Runnable() { public void run() … Read more

What is the code in android studio [closed]

if you use SOAP do sth like this : String namespace = “http://tempuri.org/” ; String soapAction = “http://tempuri.org/MyMethod”; String methodName = “MyMethod”; String url = “http://192.168.1.2:8686/WebService/MyWebService.asmx” ; // my local or valid ip for webservice location SoapObject request = new SoapObject(namespace, methodName); // your webservice argument String username = “your username”; PropertyInfo usernameProp = new … Read more