[android-developers] Re: Wake locks android

2012-12-05 Thread Streets Of Boston
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

[android-developers] Re: Wake locks android

2012-12-04 Thread G. Blake Meike
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

[android-developers] Re: Wake locks android

2012-12-04 Thread Archana
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

[android-developers] Re: Wake locks android

2012-12-03 Thread Archana
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 =

[android-developers] Re: Wake locks android

2012-11-06 Thread Glen Lee Edwards
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