错误打开移动网络设置菜单菜单、错误、网络

2023-09-13 23:43:53 作者:当你把自己的窗子打开,整个世界都会向你扑面而来。小编今天为朋

您好我想这个code。打开移动网络设置:

Hi I would like to open the mobile network settings with this code:

Intent intentSettings = new Intent();

intentSettings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intentSettings.setAction(Settings.ACTION_DATA_ROAMING_SETTINGS);
             cont.startActivity(intentSettings);

但它给我这个错误。任何想法吗?

but it gives me this error. Any ideas anyone?

12-10 11:17:34.902: ERROR/AndroidRuntime(623): android.content.ActivityNotFoundException: No Activity found to handle Intent { action=android.settings.DATA_ROAMING_SETTINGS flags=0x4000000 }

感谢

推荐答案

要得到这个工作,改变你的意图创建以下code:

To get this working, change your intent creation to the following code:

Intent intent=new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
ComponentName cName = new ComponentName("com.android.phone","com.android.phone.Settings");
intent.setComponent(cName); 

基本上Android清单需要一个组成部分过滤器。

Basically the android manifest requires a component filter.