Opening call activity from notification in lock screen

Viewed 39

I'm able to show notification that redirects to call activity when call is incoming and screen is unlocked, but that notification doesn't respond when screen lock is active. I see it, but if I click on it, no events are getting fired.

I use following code from https://developer.android.com/training/notify-user/time-sensitive

val fullScreenIntent = Intent(this, CallActivity::class.java)
fullScreenIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_USER_ACTION or Intent.FLAG_ACTIVITY_SINGLE_TOP
val fullScreenPendingIntent = PendingIntent.getActivity(
    this, 0,
    fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT
)

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

val incomingCallNotification = notificationBuilder.build()
startForeground(NOTIFICATION_ID, incomingCallNotification)

Iadded permission:

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

I've tried numerous suggestions on SO, but none of them seem to work. My activity does have required code to open above lock screen, but it's onCreate or onNewIntent newer get called from lockscreen.

Any ideas?

0 Answers
Related