Disable keyguard (Unlock device)
KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);Also remember to add permission to your AndroidManifest.xml
KeyguardLock kl = km.newKeyguardLock("MyKeyguardLock");
kl.disableKeyguard();
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
Acquire wake lock
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);Don't forget to release wake lock when your notification disabled.
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "MyWakeLock");
mWakeLock.acquire();
mWakeLock.release();The permission you need for wake lock:
<uses-permission android:name="android.permission.WAKE_LOCK" />
No comments:
Post a Comment