简体   繁体   中英

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. 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. 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. But for my application, which requires always to be connected to internet, I need a fix programatically. 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. 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. Some "rooted" phones were once able to do this, but that was disabled in 2.1 and higher.

There's no solution for this programatically. You need to toggle the network option which normally cannot be done without user intervention.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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