0

I'm developing an Video and Voice chat app.

What I need to do is to show some incoming call activity when an user try to call another user.

I'm already using Firebase Cloud Message to send push message warning the device that there is a call request.

But I'm facing a hard time trying to wake up the device and show in front of the lock screen the incoming call, so the user can accept or decline the call.

What I'm looking for is something like what Whats App does when you call some one.

enter image description here

Showing that when the device in unlocked and the app is up and running, it is not a problem.

But how can I archive this goal when the device is locked and black screen.

Community
  • 1
  • 1
Erick Gallani
  • 759
  • 8
  • 23
  • have you tried the solution mentioned in the [answer](http://stackoverflow.com/questions/3793221/how-to-display-activity-when-the-screen-is-locked) ? – Ichigo Kurosaki Aug 25 '16 at 13:00
  • Does your app have a WAKE_LOCK permission? What have you tried to do simply create a service that wakes the device? You can worry about incoming calls (which I remember seeing a similar question about, here) later – OneCricketeer Aug 25 '16 at 13:00
  • @IchigoKurosaki no I didn't found this Q&A you mentioned, I'll look that. Thank you! =D – Erick Gallani Aug 25 '16 at 13:05
  • @cricket_007 I agree with you, first I need just do wake the device and after starts to update the solution to the final solution. But that's exactly here I'm stuck. I read about the WAKE_LOCK permission, added to my Manifest but I still can figure out how to wake the device up. – Erick Gallani Aug 25 '16 at 13:08
  • check my answer at https://stackoverflow.com/a/57502344/4511297. – Prasad Pawar Aug 14 '19 at 21:38

1 Answers1

1

I was also developing this kind of app and what i did is : I used some Flags for WindowManager on that particular activity that i have to show on the screen at the time of incoming call event.

Try adding the below code in OnCreate() method of the activity that you are intend to showing on the screen.

getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                    + WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                    | +WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                    | +WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); 

And mention Following permissions in Manifest :

 <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
 <uses-permission android:name="android.permission.WAKE_LOCK" />

Hope so,it helps you.!!

Akki
  • 11
  • 1