In addition to acquiring a partial wake-lock, try to make your service a
foreground service.
This causes the service to be considered a foreground process and it shows
the user a notification on the notification bar.
See the method Service#startForeground(int id, Notification not) in the
You probably realize that just seizing a WakeLock for a long time is a
really, really horrible idea, yes? Given that, it isn't clear what you are
actually trying to do. Obviously, your service can't run when the device
is asleep
You can use the Alarm Manager in
Hi, I m doing it as part of a research project. I need my service to keep
running even when the device is asleep(until the user presses Stop button
in the App s GUI) and monitor difference in battery consumption. I used
PowerManager(implemented WiFi Locks also) because I read that CPU will be
Hi, I used the same snippet. I am also facing the same problem. The
wakelock doesnt work when the phone is unplugged. Why is that?
On Tuesday, November 6, 2012 3:57:47 AM UTC+2, Glen wrote:
pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLockOn =
pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLockOn = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
YourService.java); // PARTIAL_WAKE_LOCK forces the cpu to run even
if the screen is off
if ( wakeLockOn.isHeld() == false ) { wakeLockOn.acquire(); }
This works for me when
5 matches
Mail list logo