开发者

Error opening mobile network settings menu

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.st开发者_Go百科artActivity(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 }

Thanks


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); 

Basically the android manifest requires a component filter.


You could try getting rid of the FLAG_ACTIVITY_NEW_TASK, which may not be needed in this case, and see if that helps.

If that does not help, then either:

  • You are running this on Android 1.1 or earlier (seems unlikely)
  • You are running this on a device with a compatibility issue (if so, please let me know what device it is)
  • Something really strange is going on

UPDATE

It appears the answer is the third bullet above. While ACTION_DATA_ROAMING_SETTINGS is in the documentation, the Settings application itself does not have an <intent-filter> for it.

I will check back when the Android 2.3 source is released and see if that changes the story any. If not, I will file a bug, because either it is a documentation error or a Settings application error, IMHO.


This works the same for the ACTION_NETWORK_OPERATOR_SETTINGS, just add the following component:

Intent intent=new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS);

ComponentName cName = new ComponentName("com.android.phone","com.android.phone.Settings");

intent.setComponent(cName);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜