Question

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 ?

Was it helpful?

Solution

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.

OTHER TIPS

Yes. Otherwise, the device may fall asleep during your upload process.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top