سؤال

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 ?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top