Faizan Ahmad
Faizan Ahmad

Reputation: 362

How to use WakeLock with "PowerManager.LOCATION_MODE_NO_CHANGE"?

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).

Upvotes: 0

Views: 640

Answers (1)

MattiahIT
MattiahIT

Reputation: 87

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

Upvotes: 1

Related Questions