Show incoming voip call notification and open activity for android OS>10

Lloyd Dcosta
1 min readMar 16, 2020

--

Introduction: Simple Example

Around two weeks back, I was working on Voip/Video calling feature and I was unable to open activity for android OS version 10 via FCM notifications. When I went through the android documentation it said that there are few restrictions on starting activities from background.

https://developer.android.com/guide/components/activities/background-starts

So how do you open an activity which is in background/killed?

This can be achieved by displaying high priority notifications to the user. When creating notification make sure to include descriptive title and message. Please provide full screen intent demanding users immediate action.

Create a high priority notification

Launch a service when FCM is received. It can be done as shown below. Do not forget to add your service in Manifest. Also add the below permission in the manifest file.

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /><uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
HeadsUpNotificationService to launch headsup notification to the user when the app is in background/killed.
Headsup notification when app is in background/killed

How to handle Notification button clicks ? Well I handled it using a Broadcast receiver as below:

HeadsUpNotificationActionReceiver class to handle headsup notification button clicks.

Please comment below in case of any queries.

--

--