从应用程序打开无线设置

Den*_*son 30 settings networking wireless android

我想直接从我的应用程序打开设置 - >无线和网络.

我怎样才能做到这一点?

Dav*_*son 84

试试这个:

startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
Run Code Online (Sandbox Code Playgroud)

或者也许是startActivityForResult.你的来电.您可以通过检查" 设置"中的常量来打开不同的设置


rut*_*ash 16

您可以使用以下方式直接访问WiFi设置:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.settings", "com.android.settings.wifi.WifiSettings");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

以上在Android 3.0上不起作用,所以我最终使用:

Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)


The*_*ude 10

该代码适用于我.

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