我怎样才能开通手机网络设置画面从我的code我的、画面、手机、网络

2023-09-05 07:45:09 作者:你给的疼痛,我痛失了眼眸

我要启动移动网络设置界面,让用户可以启用/禁用3G或数据连接。谁能告诉我,我需要使用的启动活动而意图。 我用

I want to launch mobile network settings screen, so that user can enable/disable 3g or data connection. Can anybody tell me which intent I need to use for starting activity. I used

Intent in = new Intent(android.provider.Settings.ACTION_NETWORK_OPERATOR_SETTINGS ) 

Intent in = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS  ). 

但是这两个没有工作。

but both of these didn't work.

推荐答案

他们将无法工作,因为那里是固定,我认为在2.3中的错误。

They won't work because there was a bug that was fixed I think in 2.3.

请参阅 https://review.source.android.com/#/c/ 22229 /

您可以使用(用于NETWORK_OPERATOR_SETTINGS)绕过这个

You can bypass this using (for NETWORK_OPERATOR_SETTINGS)

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.phone", "com.android.phone.NetworkSetting");
startActivity(intent);

替换 NetworkSetting 设置的DATA_ROAMING_SETTINGS

Replace NetworkSetting with Settings for DATA_ROAMING_SETTINGS

有一个在Error打开移动网络设置菜单

更新

我最近测试了这一点,似乎这个解决方法还是有必要达到API级别15。由于API级16中的问题的意图似乎正常工作。

I recently tested this and it seems that this workaround is still necessary up to API level 15. Since API level 16 the intents in the question seem to work correctly.