问题
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 ?
回答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.
回答2:
Yes. Otherwise, the device may fall asleep during your upload process.
来源:https://stackoverflow.com/questions/4628058/partial-wakelock-for-3g-in-android