Android 4.0 兼容无线设置问题
|
问题:
android 4.0如何打开无线设置界面? 答案: 在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)); } |
本文探讨了在Android4.0中打开无线设置界面的问题,并提供了向前兼容的解决方案。对于不同版本的Android系统,给出了具体的Intent启动示例。

3972

被折叠的 条评论
为什么被折叠?



