How to use WakeLock with "PowerManager.LOCATION_MODE_NO_CHANGE"?

501 Views Asked by At

I am trying to use

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.LOCATION_MODE_NO_CHANGE, "My Tag");
    mWakeLock.acquire();

in onCreate method of Activity. But it is crashing my app. When I use

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag");
    mWakeLock.acquire();

It works fine. (with PPARTIAL_WAKE_LOCK).

1

There are 1 best solutions below

1
MattiahIT On

a little bit late to answer ;p ... Have you tried something like newWakeLock(PowerManager.PARTIAL_WAKE_LOCK or PowerManager.LOCATION_MODE_NO_CHANGE, "myTAG")