简体   繁体   中英

setFullScreenIntent still posting notification to the status bar

As per Android docs for setFullScreenIntent :

An intent to launch instead of posting the notification to the status bar.

Reality: Fullscreen intent is launched....but notification also gets posted to the status bar.

The screen is locked, so the user is not using the device.

    val builder = NotificationCompat.Builder(this, CHANNEL_ID)
        .setSmallIcon(android.R.drawable.ic_lock_idle_alarm)
        .setContentTitle(timer.title)
        .setContentText("Description!")
        .setPriority(NotificationCompat.PRIORITY_HIGH)
        .setCategory(NotificationCompat.CATEGORY_REMINDER)
        .setFullScreenIntent(pendingIntent, true) // tried with false too.

Any ideas why this doesn't work according to the docs?

I know I can remove the notification after it appears but the docs mention clearly that it should not appear. This is reproducible both on a real device (Android 11) and on an emulator (Android 12).

I also notice the same thing with some other apps from the Play Store. They seem to use such notification (I can't know for sure but they appear on the lockscreen as fullscreen at least).

imho thats some old mistake in docs. I've never read this methods doc so carefully, but my experience says that full screen intent was/is always show Activity ADDITIONALLY to always-present notification. or will not, then freshly posted notification will appear as heads up , eg when user is using unlocked device at the moment of notification posting

also docs shows some use cases for such feature

Only for use with extremely high-priority notifications demanding the user's immediate attention, such as an incoming phone call or alarm clock

considering call: user didn't make any touch in GUI, instead just pressed home. Phone is ringing, how to close/reject/get back to managing Activity without Notification left? such Activity won't stay in recents history ( noHistory ), you may even press this home button accidentally and you don't even know in which app looking for sound source

imho this notification should also appear with started Activity , just like it happens. It isn't even visible on screen when user starts to use your extremely high-priority Activity . When job is done and Activity is finishing then Notification may also disappear, but when user won't take any decision and it is still crucial to pick some option - he need a fast option to get back to (even accidentally) "homed"/closed Activity

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM