Android 从活动或片段调用设置屏幕

Android 从活动或片段调用设置屏幕,android,android-activity,fragment,Android,Android Activity,Fragment,我正在开发一个android应用程序,其中我必须从我的活动中调用android的无线设置活动。我正在使用这个代码 Intent i = new Intent(); final ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings"); i.setComponent(cn);

我正在开发一个android应用程序,其中我必须从我的活动中调用android的无线设置活动。我正在使用这个代码

Intent i = new Intent();
final ComponentName cn = new ComponentName("com.android.settings",
                                        "com.android.settings.WirelessSettings");
i.setComponent(cn);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
这段代码在安卓2.3.7之前运行良好,但当我在安卓4.0.1(ICS)上运行时
它给了我以下的错误

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.settings/com.android.settings.WirelessSettings}; have you declared this activity in your AndroidManifest.xml?
我查看了安卓的源代码,发现在安卓2.3.7中无线设置是一项活动,在安卓4.0.1中无线设置更改为片段。请看这两张图片。


谢谢您的帮助。

您可以使用以下代码打开无线设置屏幕

Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

但它给出了错误“ACTION\u WIRELESS\u SETTINGS无法解析或不是字段”。我将其粘贴到eclipse中,它没有在android 2.2中标识“ACTION\u WIRELESS\u SETTINGS”。您需要正确的导入使用导入android.provider.SETTINGS;