Hesam Ilyaei
Hesam Ilyaei

Reputation: 45

how to Display time-sensitive notifications in android

after restrictions on starting activities from the background in android Q I'm trying to build notification for my VOIP call using developer.android sample code but it's not working can you please help me to fix this issue ?

this code below is sample that I'm using to build time-sensitive notifications :

  Intent fullScreenIntent = new Intent(this, CallActivity.class);
                    PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(this, 0,
                            fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT);

                    NotificationCompat.Builder notificationBuilder =
                            new NotificationCompat.Builder(this, CHANNEL_ID)
                                    .setSmallIcon(R.drawable.notification_icon)
                                    .setContentTitle("Incoming call")
                                    .setContentText("(919) 555-1234")
                                    .setPriority(NotificationCompat.PRIORITY_HIGH)
                                    .setCategory(NotificationCompat.CATEGORY_CALL)
                                    .setFullScreenIntent(fullScreenPendingIntent, true);

                    Notification incomingCallNotification = notificationBuilder.build();

Upvotes: 0

Views: 2362

Answers (1)

Lucien Davison
Lucien Davison

Reputation: 176

Since you are on Android 10, you need to request the USE_FULL_SCREEN_INTENT permission. In your AndroidManifest.xml:

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

See: https://developer.android.com/about/versions/10/behavior-changes-10#full-screen-intents

Upvotes: 2

Related Questions