Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android link to wireless & Network Settings

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.

like image 710
iamlukeyb Avatar asked Mar 07 '12 11:03

iamlukeyb


2 Answers

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);
    }
});
like image 185
Aleks G Avatar answered Sep 29 '22 13:09

Aleks G


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

like image 27
Muhammad Noman Avatar answered Sep 29 '22 14:09

Muhammad Noman