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