月份: 2020-06

调用Android Wifi 设置的方法

不同系统不同版本的Android 的 wifi setting 的 Activity 不尽相同,下列方式应该可以用的,具体Activity 的 ClassName 要看机型和烧录的 Android ROM 。。。
Android 通过应用包名启动外部应用方式A

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ComponentName comp = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings");
mIntent.setComponent(comp);
startActivity(mIntent);

Android 通过应用包名启动外部应用方式B

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ComponentName comp = new ComponentName("com.android.settings", "com.android.settings.Settings$WirelessSettingsActivity");
mIntent.setComponent(comp);
startActivity(mIntent);

Android 通过应用包名启动外部应用方式C

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ComponentName comp = new ComponentName("com.android.settings", "com.android.settings.wifi.WifiSettings");
mIntent.setComponent(comp);
startActivity(mIntent);

Android 通过应用包名启动外部应用方式D

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ComponentName comp = new ComponentName("com.android.phone", "com.android.phone.NetworkSetting");
mIntent.setComponent(comp);
startActivity(mIntent);

Android 通过应用包名启动外部应用方式E

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ComponentName comp = new ComponentName("com.android.phone", "com.android.phone.Settings");
mIntent.setComponent(comp);
startActivity(mIntent);

广播Intent A

Intent i = new Intent("android.settings.WIRELESS_SETTINGS");
mContext.sendBroadcast(i);

广播Intent B

startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));