31

I want to open the Settings-> Wireless & networks directly from my application.

How can I do that?

Janusz
  • 187,060
  • 113
  • 301
  • 369
Dennis Gimbergsson
  • 343
  • 1
  • 5
  • 7

7 Answers7

88

Try this:

startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));

Or perhaps startActivityForResult. Your call. You can open different settings by checking the constants in Settings

David Olsson
  • 8,085
  • 3
  • 30
  • 38
  • Question : How can we open "Input Languages" Activity like this ? – Tushar Pandey Aug 08 '14 at 09:35
  • you can use also this for direct data enable check box.. Tested..on samsung.. startActivity(new Intent( android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS)); – CrazyMind May 26 '16 at 13:10
  • 1
    Using this get's you straight to WIFI settings for anyone who just wanted that. startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS)); – Michael Aug 26 '16 at 17:14
16

You can access the WiFi settings directly using this:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.settings", "com.android.settings.wifi.WifiSettings");
startActivity(intent);

The above did not work on Android 3.0, so I ended up using:

Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
startActivity(intent);
rutash
  • 161
  • 1
  • 5
  • Works on Android 4.0.3, but not on 3.0. I ended up using something even simpler. See above. – rutash Aug 15 '12 at 20:21
11

That code works for me.

startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));

The Dude
  • 347
  • 4
  • 11
2

use the below code to call wireless and networks directly from your application.

Intent intent=new Intent();
            intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.WirelessSettings"));
            startActivity(intent);
ilango j
  • 5,967
  • 2
  • 28
  • 25
1

Use Following Function For Open WI_FI Settings

private void openWifi() {
    Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
    startActivity(intent);
}
Quantum4U
  • 35
  • 4
0

i tried solutions above and it give me error that if you want to open external open you should flag that intent with FLAG_ACTIVITY_NEW_TASK
here is my solution in kotlin

val intent = Intent(Settings.ACTION_WIFI_SETTINGS)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(getApplication(), intent, null)
nima moradi
  • 2,300
  • 21
  • 34
0

This work for me, kotlin in 2022.

 val context = LocalContext.current

 fun onEnableConnection() {
     startActivity(context, Intent(Settings.ACTION_WIFI_SETTINGS), null)   }