Difference in ways of maintaining Notifications - android

What is the difference between the function FLAG_ONGOING_EVENT and FLAG_NO_CLEAR how do they make the Notification behave differently? Do they both make the Notification permanent.

Documentation says :
FLAG_ONGOING_EVENT: Bit to be bitwise-ored into the flags field that should be set if this notification is in reference to something
that is ongoing, like a phone call. It should not be set if this
notification is in reference to something that happened at a
particular point in time, like a missed phone call.
FLAG_NO_CLEAR :Bit to be bitwise-ored into the flags field that should
be set if the notification should not be canceled when the user clicks
the Clear all button.
I think in these words they have different meanings so mixing these flags will give you a permanent notification until your program process ends , if you use just FLAG_ONGOING_EVENT this cause your notification runs until your binding service like phone call ends and it's also cancelable by developer or it can be clear by user and when you mix it with the other, user can't clear it from status bar.

Related

How Do I Get Rid of the Progress Indicator for RemoteInput Notifications on Android N?

I used RemoteInput to allow the user to enter some text as part of a Notification on N Developer Preview 1. It worked, but when the user pressed the "send" button, an indefinite progress indicator appeared, and it never goes away:
Is this supposed to happen? How do I get rid of it?
Is this supposed to happen?
Apparently, yes.
How do I get rid of it?
Update the Notification. That could:
Add back in the RemoteInput to accept new input, or
Not add back in the RemoteInput, but perhaps update other aspects of the Notification to indicate that you have received and processed the input
Or, if appropriate, cancel() the Notification.
This sample project demonstrates the use of RemoteInput with the N Developer Preview.

is there any listener after performing clear notification in android?

Basicly I want to do something after the user clear my notification from the top bar, How do I do that in andorid programmatically?
Basic example or complete code would be nice thanks.
When you create a Notification,setDeleteIntent ,Here is the api:
setDeleteIntent(PendingIntent intent)
Supply a PendingIntent to send when the notification is cleared explicitly by the user.

IconLevel and startForeground

I would like to animate the icon of the app without having to cancel the notification and create a new one (because in this way the icon doesn't stay in the same position of the notification bar but could move to first place if there are other notification running).
I'm able to get this with normal notification, but I would like to get the same behaviour when I use startForeground in my service. This method launches a new notification which can't be removed unless you remove service from foreground using stopForeground.
Is this possible to do? How?
Use the same notification ID for the startForeground method and the Notification object.

Status bar Notification in android

I want to set a onClickListner for a status bar Notification. How it is possible ? Please help. Now i can load a Activity by using the pending intent. I like to set a onClickListner for the notificatioin.
Regards
Parvathi
It is not possible to set an OnClickListener for a notification. Because of the way notifications are handled/displayed there is no way to guarantee that the process that created the notification will be running at the time the notification is clicked. This means that any code you wrote to provide click handling may not be running.
If you need click listener style behavior you will have to do it using the PendingIntent: set it to start a Service that runs the logic or to use an Intent that is received by a BroadcastReceiver. This will let you perform activity without requiring a UI.

How to reset notificationmanager number on notification clear

What's the best way to clear the notification number when the user clicks on the notification? I say the best way, but really I haven't found ANY way. I'm launching a built in activity when the user clicks on the notification, not something I wrote so I can't clear it that way. I've got the notification manager's flag set to clear
NotificationManager notification
.
.
.
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.number++;
nm.notify(1,notification);
But whatever I do the Notification.number keeps going up and never resets to 0.
You could use an intermediary activity which is part of your app and thus can reset your variable and then start the internal activity.
So the chain would be
Notification --starts--> Intermediary Activity --starts--> Built-in activity
I am using a combination of what #CommonsWare recommends and extending an application object as here How to update notification number .
Edit: Further testing shows that actually this is not working because the BroadcastReceiver is called on every notification and because it reset the number on every notification the number is never correct.

Categories

Resources