12

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.

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
iamlukeyb
  • 6,487
  • 12
  • 29
  • 40
  • 2
    See http://stackoverflow.com/questions/2318310/how-can-i-call-wi-fi-settings-screen-from-my-application-using-android – chedabob Mar 07 '12 at 11:46

3 Answers3

34

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);
    }
});
Aleks G
  • 56,435
  • 29
  • 168
  • 265
10

If you use Settings.ACTION_SETTINGS then user can go in both settings mobile network and wifi.

Muhammad Noman
  • 1,842
  • 19
  • 14
0

you can use this code for open page mobile network

startActivity(new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS));
Corion
  • 3,855
  • 1
  • 17
  • 27