I’m trying to show a full-screen intent with my notification (running on a android 13 device). The notification is sent, but the intent isn’t opening.
I’ve granted the required permissions and my manifest content is as follows:
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<activity
android:name=".RingActivity"
android:exported="false"
android:showOnLockScreen="true"
android:turnScreenOn="true" />
<receiver android:name=".infrastructure.Receiver" />
Here’s the relevant code for creating the notification and full-screen intent:
private fun createChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val importance = NotificationManager.IMPORTANCE_HIGH
val channel = NotificationChannel("my_channel_id", "Alarm", importance)
val notificationManager: NotificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)
}
}
private fun notify(alarm:Alarm, intent:Intent){
createChannel()
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
val builder = NotificationCompat.Builder(context, "my_channel_id")
.setSmallIcon(android.R.drawable.arrow_up_float)
.setContentTitle("title")
.setContentText("description")
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_ALARM)
.setFullScreenIntent(pendingIntent,true)
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED
) return
NotificationManagerCompat.from(context).notify(alarm.id,builder.build())
}
Can anyone help me figure out why the full-screen intent isn’t opening?
*this is the intent im trying to call :
val intent = Intent(context,RingActivity::class.java).also {
it.flags = Intent.FLAG_ACTIVITY_NEW_TASK
it.putExtra("id",alarm.id)
}
Thank you so much for your help! I managed to fix the issue. It turned out that the problem only occurred when I scheduled the notification with a short delay. It works fine with longer delays now