简体   繁体   English

如何从wifi编程出来后解决在android中丢失的移动数据连接(2G / 3G / EDGE / GPRS)?

[英]How to resolve mobile data connection(2G/3G/EDGE/GPRS) lost in android after coming out from wifi programatically?

I need a fix for this strange problem appearing in android. 我需要针对出现在android中的这个奇怪问题的修复程序。 Sometimes I notice that even I have full cellular network, data network is lost.(Not able to connect to internet although have all set properly). 有时我注意到即使我拥有完整的蜂窝网络,数据网络也会丢失。(尽管所有设置都正确,但无法连接到互联网)。 This possibly occurs after I leave wifi. 我离开wifi后可能会发生这种情况。 A quick fix to make it working is toggle 2G/3G option in settings --> Mobile Networks, which probably clears the network stack and makes it all working. 要使其正常运行,一个快速解决方案是在设置->移动网络中切换2G / 3G选项,这可能会清除网络堆栈并使它们全部正常工作。 But for my application, which requires always to be connected to internet, I need a fix programatically. 但是对于我的应用程序(它总是需要连接到Internet),我需要以编程方式进行修复。 I cannot toggle that from code ? 我无法通过代码切换该代码吗? Or can I ? 还是可以吗?

I read and tried a fix by rewriting APN settings, but that do not solve the issue entirely, as we move out from wifi connectivity. 我阅读并尝试通过改写APN设置来解决此问题,但是随着我们从wifi连接中撤出,这无法完全解决问题。 Do anyone have any fix for this from code ? 有人从代码中对此有任何解决办法吗?

Because of the way Android networking and security work, there's no way to toggle 2G/3G-4G without going into settings. 由于Android网络和安全性的工作方式,如果不进行设置就无法切换2G / 3G-4G。 Some "rooted" phones were once able to do this, but that was disabled in 2.1 and higher. 一些“有根”的电话曾经能够做到这一点,但是在2.1及更高版本中已被禁用。

There's no solution for this programatically. 以编程方式没有解决方案。 You need to toggle the network option which normally cannot be done without user intervention. 您需要切换网络选项,这通常需要用户干预才能完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM