How to display a Call Activity when the device is locked and the display is off

0

I'm developing a Video and Voice app.

What I need is to show an activity the call request when one user tries to call the other.

I'm already using the Firebase Cloud Message to send push messages to the device, notifying them that they have a call request.

But I'm having some problems trying to wake up the device and show the call activity in front of the lock screen for the user to accept or reject the call.

What I'm trying to do is similar to what WhatsApp does when you receive a call.

Show this when the device is unlocked and the app is in foreground is not difficult, my difficulty is exactly in showing this when the device is locked and in rest mode (black screen).

    
asked by anonymous 25.08.2016 / 15:10

2 answers

0

One of the things you need to know is basically Run a Background Service on Android . Remembering that to create a service, you must create a subclass of Service that in your implementation, you need to overload some call methods that handle key aspects of # and provide mechanisms for components to connect to the service as shown in the diagram below.

  

A service is in the "Started" form when an application component   (as an Activity) starts it by calling startService ().

Do you know that you will face many problems when it comes to this? So I advise you to take a look at Q-municate , which is a project Open Source super cool that uses the Quickblox . Download it and import a project and study it a lot. You're sure to learn a lot.

Note that in this diagram there are several different returns of other methods in the return path.

    
25.08.2016 / 15:57
0

I think what you are looking for is one of the new features introduced by Lollipop (API21) in the notification system.

Using the new visibility property of the Notification in>, it is possible to tell the system when and how it should reveal the presence and contents of a notification.

There are 3 types of "visibility":

  • Secret (Notification.VISIBILITY_SECRET) - The notification is considered sensitive and is not shown in the "lock screen" . This is the default behavior (default).
  • Private (Notification.VISIBILITY_PRIVATE) - Notification is considered sensitive only with respect to content. It is displayed in the "lock screen" but the content of the message is replaced by "Contents hidden" .
  • Public (Notification.VISIBILITY_PUBLIC) - The notification is considered non-sensitive and the notification is fully displayed in the "lock screen"

The property can be "set" using Notification.Builder .

Notification notification  = new Notification.Builder(this)
  .setCategory(Notification.CATEGORY_MESSAGE)
  .setContentTitle(title)
  .setContentText(text)
  .setSmallIcon(icon)
  .setAutoCancel(true)
  .setVisibility(Notification.VISIBILITY_PUBLIC).build();
NotificationManager notificationManager = 
                        (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(notification_id, notification );

Note : This property is only available from API21. Appcompat makes it accessible and can be used, but its effect is only felt on a device with Android 5 or higher.

    
25.08.2016 / 18:45