I have a service that uploads file to a server. I acquire a wifilock on it but do I need a partial wakelock if the service is using 3G ?
Asked
Active
Viewed 2,096 times
1
-
please share your code for partial wake lock. as I am in problem. – AZ_ Mar 01 '11 at 14:35
2 Answers
3
Yes. Otherwise, the device may fall asleep during your upload process.

CommonsWare
- 986,068
- 189
- 2,389
- 2,491
-
the device does fall asleep but I tested the application for half an hour (unplugged from usb) and it kept on uploading so still kind of confused but I guess to be on safe side I should just acquire the lock ? – 2cupsOfTech Jan 07 '11 at 23:06
-
@Tabish: Really? I was aware that incoming packets on a 3G connection would wake up the phone. That might be helping keep your device awake in that scenario. I'd use a `WakeLock` to be safe, though. – CommonsWare Jan 07 '11 at 23:10
-
1If you need the CPU to keep running, you need to hold a wake lock. Many other things can hold wake locks that happen to keep you running, but if you don't hold one yourself you have no guarantee if working correctly. – hackbod Jan 08 '11 at 08:21
-
shouldn't this be required for wifi too ? I acquire a wifilock for wifi but not the partial wakelock and it works fine – 2cupsOfTech Jan 10 '11 at 18:58
-
@CommonsWare does the Wifi lock does also affect 3G / 4G connections? – nAkhmedov Jan 19 '17 at 12:23
-
1
1
WakeLock is an Inefficient way of keeping the screen on. Instead use the WindowManager to do the magic. The following one line will suffice the WakeLock. The WakeLock Permission is not needed for this to work. Also this code is efficient than the WakeLock.
getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
You need not relase the WakeLock Manually. This code will allow the Android System to handle the Lock Automatically. When your application is in the Foreground then WakeLock is held and else android System releases the Lock automatically.

Anoop Chandrika HarisudhanNair
- 4,910
- 4
- 29
- 48
-
For using Wifi you need the WifiLock and associated permission. – Anoop Chandrika HarisudhanNair Apr 05 '11 at 07:33
-
1