i wrote an android alarm program. it work properly in many devices but in some device when the screen in on the alarm activity open and alarm work properly, but in some device it is not work when the screen is off. please help me in write code for disable keyguard lock and then keep the screen on until the user click on one button. thanks for your help...
Asked
Active
Viewed 1,802 times
1 Answers
0
in your AndroidManifest give the following permission :
<uses-permission android:name="android.permission.WAKE_LOCK" />
and in java file :
PowerManager powerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Lock");
wakeLock.acquire();
release this lock when application is paused or destroyed or on button click:
wakeLock.release();
hope it helps.
few links :
disable-keyguard-and-display-an-activity-to-the-user
disabled-keyguard-lock-re-enables-itself-after-clicking-on-a-notification

Community
- 1
- 1

Kushal Sharma
- 5,978
- 5
- 25
- 41
-
Hello, thank you, but in this sample code screen does not turn on and keyguard not dismiss. please complete it. i am waiting... :) – Muhammad Ali Sep 20 '14 at 18:31
-
i cannot write code for you. i have updated asn with a few links. please go through and come up with doubts if any. regards – Kushal Sharma Sep 20 '14 at 18:37
-
please see this link http://stackoverflow.com/questions/25930764/activity-alarm-do-not-turn-on-screen-in-sony-xperia-p-when-alarm-played this is my sample code but in some device it doesn't work... – Muhammad Ali Sep 20 '14 at 18:50
-
Hello dude, i research my problem and understand that in KitKat for increasing performance, CPU go to sleep in specific time after we lock it and we must use alarmManager.setExact... instead of alarmManager.set... in my code when my Android SDK version is KitKat and up. thanks again. – Muhammad Ali Jan 09 '15 at 07:52