0

many things has been written about wakelocks in Android. I'm using wakelock this way:

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
partialWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Partial");
partialWakeLock.acquire();
// few hours work
partialWakeLock.release?

In most of devices, PARTIAL_WAKE_LOCK can keep device running whole night. But there are few models (Samsung Galaxy ACE 2 (i8190) - 4.1.2 etc.), which ignore this kind of wakelock. Wakelock is held, but phone goes to sleep if device's screen is turned off.

Is there some way how to determine, if application is running in device with this problem? I can let user turn devices's screen off for a few seconds and check if work has been done, but is there some automatic way?

Thanks in advance.

skywall
  • 3,956
  • 1
  • 34
  • 52
  • Where is the code used ? Services etc ? Edit your question adding info on that – Mr_and_Mrs_D Jan 30 '15 at 15:20
  • @Mr_and_Mrs_D Thanks for answer. In the `Service`. I have actually solved the problem. There isn't problem with wakelock at all, but in accelerometer which doesn't produce values when screen's off. The solution is based on running thread witch partial wakelock and trying to grab some values. If there are no received sensor values, we can mark this particular device as buggy. – skywall Jan 31 '15 at 10:57
  • consider posting your comment as an answer giving more details – Mr_and_Mrs_D Feb 01 '15 at 17:14

0 Answers0