Reputation: 5954
I have created a custom incoming call screen with Answer, cancel and other things to the activity it is working fine, but when the phone is on sleep mode it doesn't wake up on incoming call. How to fix this wake up on the incoming call part?
Also the same case with when the phone is locked I have to unlock and accept the call?
Can somebody guide me to fix this too?
Let me know!
Thanks!
Upvotes: 1
Views: 1952
Reputation: 159
Use Window flags when you start your activity to turn/keep the screen on and dismiss the keyguard.
For example, call this code on the onCreate() of your call screen:
WindowManager wm= (WindowManager) getSystemService(WINDOW_SERVICE);
Window window=getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Try the different flags and choose the ones that better suit the behaviour of your App.
Upvotes: 3