android Wifilock- How about mobile data access lock?
Asked Answered
R

1

6

If there's a wifiLock for acquiring wifi and enabling it to work even when the phone goes idle and sleep, is there happened to be a counterpart of it for mobile data access?

You see, everything goes well now if the user is in wifi connection. But somehow, using mobile data access, and when the phone goes idle, it seems to be dropping the connection. Any ideas?

Railing answered 18/11, 2012 at 13:13 Comment(0)
P
5

Mobile data does not go to sleep. However, if your socket remains open and unused for a while, it may get shut down. That's why C2DM (and, presumably, GCM) had to send a heartbeat every 30 minutes or so, to make sure the open socket connection to Google's servers remained open.

Parnassian answered 18/11, 2012 at 13:21 Comment(5)
is that so? how come I'm not receiving online messages from my phone when I'm on mobile data access. But it works just fine on wifi ever since i've been using wifi lock and wake lock. Thanks.Railing
@mai: "how come I'm not receiving online messages from my phone when I'm on mobile data access" -- I have no idea. I am not you, I am not a mind reader, I did not write your code, and I have no idea what "online messages" you are referring to. I recommend that you watch the 2010 Google I|O conference video on C2DM (the precursor to GCM), where they discuss some of what they had to do to make it work: youtube.com/watch?v=PLM4LajwDVcParnassian
So, Mobile Data network isn't turned off even in deep sleep mode unlike WiFi on old android devices? And the same is true for 6.0+ devices too? (I mean in doze mode)Bahaism
@Jenix: The mobile radios are always on, typically in a low-power mode. Otherwise, you could not receive phone calls and text messages. Those things wake up the device out of sleep mode. On Android, they also rigged it up that incoming packets on open mobile data connections will wake up the device out of sleep mode. However, apps affected by Doze are blocked from establishing new network connections. That's why Play Services is on the battery optimization whitelist, to avoid this aspect of Doze behavior.Parnassian
Thanks a million. You are everywhere on stackoverflow haha. I could solve lots of problems thanks to you!Bahaism

© 2022 - 2024 — McMap. All rights reserved.