I have an app that carries out a task for the user in the background (using a foreground service).
This has a notification with two action buttons, one of which starts an Activity.
In Android 11, when the user tapped on the action button that starts the Activity, I sent a broadcast using the CLOSE_SYSTEM_DIALOGS action, which would dismiss the notification tray so that the user could see the new Activity.
Apps aren't allowed to use the CLOSE_SYSTEM_DIALOGS intent action any more, but I don't see any alternative.
https://developer.android.com/about/versions/12/behavior-changes-all#close-system-dialogs
It's a really clunky experience for users to have to press the action button, then close the notification tray manually.
Is there any other way to dismiss the notification tray when the user taps an action button?
Related
An android foreground service needs a notification, which is fine, but I would rather have it go directly to the notification background without first obscuring the UI for 3 seconds.
Is there a combination of settings for the notification builder and or the notification channel, which will give me the small icon in the notification bar as well as the notification, when expanding the notification list, but without showing a notification on top of the ui for about three seconds?
My issue is not that I want to hide anything, but rather that the application is in use by the user after the foreground service is being started, so the popup is annoying.
I'm building an Android app which creates notifications. Each notification has a number of additional actions.
The default application (when the user taps on the notification) launches an activity in my app. That's working fine.
When the user swipes the notification to dismiss the notification, my app responds by doing some deletion work, and the user is left on the list of notifications. The one that the user swiped is removed from the list.
For some of my additional actions I want to launch activities, and that's working fine; for the other actions, I want my app to do some work but I also want the user to remain on the notification list. I'm struggling to find a way to do this last part - all my attempts to configure the intent and pending intent for my additional action result in behaviour whereby when the user clicks on the action, the notification list disappears.
Is there any way to get what I want (i.e. a notification additional action which performs work but leaves the user on the notification list)? Do I need to build a custom notification layout or something?
My application adds a notification in the notification bar. Now when user clicks the notification, is there a way to execute some code inplace rather than control is redirected back to my app.
Let the user be in notification area after clicking this notification and the click does the work in some background task or service.
Is it possible to send a handler message in this case
Update to question:
If I wish to have 2 buttons in the notification. where would the handling code run
That should be an easy one. Just use an IntentService:
http://developer.android.com/reference/android/app/IntentService.html
and here the first tutorial I found on google:
http://mobile.tutsplus.com/tutorials/android/android-fundamentals-intentservice-basics/
I have a notification that notifies that a long operation has succeeded and offers the user to do something after that.
Leaving the notification aside and opening the app, makes the app apear in the recents - even when the back is pressed and the activity stack is left empty.
The problem is that when the user clicks on the notification, the notification intent is then registers in the recents - instead of the app's main activity. Clicking on the recents over and over again does the notification intent action instead of popping up the app.
How can I have the app stay in recents instead of the last notification intent?
Notes:
When the app's activity stack is not empty, everything works perfect!
FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS is not acceptable because it removes the app altogether from the recents instead of just the notification intent.
I have a background service setting up a notification in Android's status bar. The background service is doing some work, but needs to stop when the user clicks on or cancels the notification.
I am able to stop the service, if the user clicks on the notification by passing an intent to the notification when creating it.
Is it possible to react if the user cancels the notification? Or if all notifications are canceled? If so, how?
NB: I define cancel as removing the notification by swiping to the right on it, or clicking on the x at the top right to remove all the notifications.
Check out the deleteIntent of the Notification:
The intent to execute when the status entry is deleted by the user with the "Clear All Notifications" button.