Dennis Gimbergsson
Dennis Gimbergsson

Reputation: 363

Open wireless settings from app

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

How can I do that?

Upvotes: 33

Views: 46187

Answers (7)

Magali Defelippe
Magali Defelippe

Reputation: 1

This work for me, kotlin in 2022.

 val context = LocalContext.current

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

Upvotes: 0

nima moradi
nima moradi

Reputation: 2628

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)

Upvotes: 0

Quantum4U
Quantum4U

Reputation: 35

Use Following Function For Open WI_FI Settings

private void openWifi() {
    Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
    startActivity(intent);
}

Upvotes: 1

The Dude
The Dude

Reputation: 365

That code works for me.

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

Upvotes: 12

rutash
rutash

Reputation: 171

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);

Upvotes: 17

ilango j
ilango j

Reputation: 6037

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);

Upvotes: 2

David Olsson
David Olsson

Reputation: 8225

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

Upvotes: 90

Related Questions