Hi I'm making an App that checks internet connection, if it's not connected it goes to an activity that has an error message and a button that I want to link to the wireless and network settings. But I'm not sure how to do it, can anyone help me ?
Here's what I've got so far.
public class NetworkActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.networkact);
Button settings = (Button) findViewById(R.id.btn_settings);
// Listening to button event
settings.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// Starting a new Intent
Intent gotoSettings = new Intent(getApplicationContext(),
HomeActivity.class);
startActivity(gotoSettings);
}
});
}
}
At the moment it goes to another activity but I want it to go to the wireless & network settings.
I believe, what you want is this:
btn = (Button)this.findViewById(R.id.ButtonNet);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(Settings.ACTION_WIRELESS_SETTINGS);
startActivity(intent);
}
});
If you use Settings.ACTION_SETTINGS then user can go in both settings mobile network and wifi.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With