Open wireless settings from app

2019-01-31 00:47发布

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

How can I do that?

5条回答
手持菜刀,她持情操
2楼-- · 2019-01-31 01:18

Use Following Function For Open WI_FI Settings

private void openWifi() {
    Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
    startActivity(intent);
}
查看更多
老娘就宠你
3楼-- · 2019-01-31 01:19

That code works for me.

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

查看更多
SAY GOODBYE
4楼-- · 2019-01-31 01:20

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

查看更多
Deceive 欺骗
5楼-- · 2019-01-31 01:31

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);
查看更多
虎瘦雄心在
6楼-- · 2019-01-31 01:32

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);
查看更多
登录 后发表回答