以编程方式启动移动网络设置屏幕 [英] Launching mobile network settings screen programmatically

查看:53
本文介绍了以编程方式启动移动网络设置屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要启动移动网络设置屏幕,以便用户可以启用/禁用3g或数据连接。有人可以告诉我开始活动时需要使用哪种意图。我使用的

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

  =新的Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS)。 

但两者都不起作用。

解决方案

它们不起作用,因为我认为在2.3中已修复了一个错误。



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



您可以使用(对于NETWORK_OPERATOR_SETTINGS)跳过此操作

  Intent intent =新的Intent(Intent.ACTION_MAIN); 
intent.setClassName( com.android.phone, com.android.phone.NetworkSetting);
startActivity(intent);

NetworkSetting >针对DATA_ROAMING_SETTINGS的设置

还有另一种类似的解决方案,在打开移动网络设置菜单时出错



更新



我最近对此进行了测试,看来直到API级别15仍需要此解决方法。自API级别16起,问题的意图似乎可以正常工作。


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 ) 

and

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

but both of these didn't work.

解决方案

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

See https://review.source.android.com/#/c/22229/

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

Replace NetworkSetting with Settings for DATA_ROAMING_SETTINGS

there's another similar solution described in Error opening mobile network settings menu

UPDATE

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.

这篇关于以编程方式启动移动网络设置屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆