setFullScreenIntent still posting notification to the status bar - android

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, e.g. 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

Related

Check if "setFullScreenIntent" leads to a launch of the application or to the display of a notification

I get a firebase notification and create a NotificationCompat.Builder with the "setFullScreenIntent" option. This leads to different behaviours on different systems or different device status.
Sometimes the app launches directly, sometimes a notification is displayed.
I have to surpress a ringtone if the user clicked on the notification but play it when the app starts directly.
How do I get to know which one happened when my activity starts?
Sorry for my English.
You can do cancel the Notification in activity#onCreate or other lifecycle where you want

Notification sent via PendingIntent does not show up

In one of Activity-derived class methods I'm trying to send a Notification, clicking on which will bring the Activity to foreground if my app is in background (not visible) right now. There are reasons why I don't use Service, but use Activity (that will hold PARTIAL_WAKE_LOCK) for that.
I remember Notification worked for me when I used it like this, but I sent it from Service. Now when I send it from Activity method and it doesn't show up, though I hear its notification sound.
So are there any reasons that prevent Notification show up sent from Activity method and how can it be solved?
Thank you.
I was not exactly precise copying Notification code sample. I removed setSmallIcon() call from code as I was too lazy to add icons. As a result system was really dropping my Intent, saying that no icon is provided for it and it'll be a crash in future releases.

Is it possible to move a notification from heads-up to the status bar?

Background
Android Lollipop (API 21) introduced a way to show notifications outside of the status bar (AKA "notifications bar"), so that the user can handle them right away. It's called "Heads-up notifications".
The trigger for showing them may vary between devices/roms/manufacturers.
The problem
Sometimes, showing such notifications can annoy users, and most of the times there are no settings for those cases.
If the user dismisses heads-up notifications, they won't show as a normal notification. There is no way to hide them and continue with what's on the screen. You can only wait (and it's quite a long time of waiting too).
In fact, there are multiple Google-Group issues that were opened about it, just because it can annoy people (link here and here).
What I've found
Starting with API 18, it is possible to listen to notifications events and even read them, by using "NotificationListenerService" and "StatusBarNotification" , and maybe other classes.
However, other than dismissing notifications (of other apps), I can't find any other action that can be done to them.
The question
Is it possible that in the lifetime of my app, I will be able to listen to notifications that are shown as heads-up, and put them back as a status-bar notifications?
Maybe even set a different timeout for them? or choose to convert them to normal status-bar notifications when they get dismissed?
Maybe before even doing those operations, I should ask: how can I know if a notification that I've found (of other apps) is showing as a heads-up notification ?
I don't know how to do implement this. But answering the "Is it possible that...?" question, yes, there are apps like this one that block/only show notifications in the notification bar.

Bringing my Alarm to the front

I had a few problems with my alarm that are in a another thread here if anyone could help but anyway here is a new question. If I set an alarm using my app, say for 5 minutes from now, and then close the app, how would I code it so that my app activity comes back to the front?
This is basically the same as the clock app already on most android phones. I'm doing this to allow the user to stop the alarm. Would I be right in saying that I would have to modify my existing code to, when the alarm is run, launch a new intent to bring the activity to the front? Or can I simplify this and only have an alertdialog or something open instead of opening the entire app?
Any links would be appreciated
Thanks
Don't move your activity to the front automatically. It's as annoying as a pop-up ad! Do you really want to try to interrupt the user who's trying to look up a phone number?
Instead, use a Service. When you want to tell the user something, post a status bar notification. You can set up the notification to bring up an Activity when the notification is clicked.
Most alarms are implemented in a Service.
Have you looked into the AlarmManager? http://developer.android.com/reference/android/app/AlarmManager.html. I've used it in the future to fire Intents for Notifications. The Notification can then open an Activity for the user when they select the Notification from the Android Notification Bar.

Android: Display Notification as an activity instead of adding it to status bar

I m a newbie to android development and i wanna know a right way to get notification as an activity instead of statusbar notification.
To be clear, i wanna display an notification on screen instead of adding it to status bar.
In that case you shouldn't call it notification. In Android, a notification is something that ends up in the status bar and that the user can deal with at her own leisure.
An activity will take over the complete screen and force the user to deal with it immediately. That is very intrusive and users will likely get annoyed, unless the information you show is really crucial.
The correct behaviour is to post a notification and bring up your activity when the user clicks on the notification, very much like your messaging client or email client.
Other options are bringing up a dialogue or a toaster message. A dialogue is a message the user will have to interact with to go away, whereas a toaster message will be visible for a short time and then automatically disappear.
Maybe you could be a bit more specific about what sort of information you want to provide to the user?
Surely you can be helped out.
I feel that you are getting notifications from a web service as a response to some request, right?
If yes, then you can display them in a custom made dialog box, or inside an activity whose theme has been set as DIALOG.
maybe I got your question wrong, maybe your talking about the notifications about networks, calls and things.
If its so, correct me.
Thanks!
Android 2.3 introduced a new field on Notification, fullScreenIntent, for exactly this purpose. Place a PendingIntent here that will trigger whatever activity you'd like to display, and the user will be sent to that activity (whether full-screen or dialog-themed) in addition to receiving the usual notification icon in the status bar. As of Gingerbread, this is how the Phone app implements the incoming call screen.

Categories

Resources