Hi i am making an Alarm Application. When Alarm Time Comes i Am showing user a Dialog. But the problem is i want to acquire the wake lock when dialog appears. just like when an sms received the screen just wakes.
i have try this one but is not working
public class Alarm extends Activity{
PowerManager pm;
WakeLock wl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pm = (PowerManager) getSystemService(POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "FlashActivity");
wl.acquire()
showAlarmDialog();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
wl.release();
}
}
I have added the wakelock permission too. Help Would be appriciated :-)
I was able to Turn the screen on this way:
wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
wl.acquire();
Hope This help. It Worked For me Though :-) Cheers
You can acquire wake lock by two methods
wl.acquire(); or wl.acquire(timeout)
Try some thing like this in onResume():
PowerManager pm;
WakeLock wl;
pm = (PowerManager) getSystemService(POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "FlashActivity");
wl.acquire(); Or wl.acquire(timeout)
And you are realeasing in onPause(). That is good.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With