在android4.0之前可以通过下面方法打开无线网络设置页面,可是在4.0以上则会抛异常 Intent mIntent = new Intent("/"); ComponentName comp = new ComponentName( "com.android.settings", "com.android.settings.WirelessSettings"); mIntent.setComponent(comp); mIntent.setAction("android.intent.action.VIEW"); startActivityForResult(mIntent, 0); 那么有什么方法进行兼容吗? 经过尝试采用下面的方法startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));可以兼容4.0之前及之后的版本,不过由于android3.0之后设置界面改动很大,所以个人采用下面的方法打开网络设置 if(android.os.Build.VERSION.SDK_INT > 10 ){ //3.0以上打开设置界面 context.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS)); }else { context.startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS)); } 转自:http://www.eoeandroid.com/thread-182211-1-1.html |
android 4.0如何打开无线设置界面?
最新推荐文章于 2023-04-27 22:23:27 发布