Is it possible to set how long a notification is displayed in android API level 10 or lower?
Asked Answered
C

2

8

Research

I've been looking through the NotificationManager class in the android documentation for API level 10 and haven't found a way to implement this. I also looked around on google but only found how to set the time at which the notification is actually set and how to set the length of time a toast notification widget is displayed.


Currently Implemented

I have already set the FLAG_NO_CLEAR and FLAG_ONGOING_EVENT to keep the notification icon present as well as keep the notification visible after expanding the notification drop-down.


Attempting to Do

I am attempting to display the text of the notification in the notification bar for 10 seconds instead of the standard amount of time. So I would basically like to do exactly what the setDuration(int) function does in the toast widget.

I was wondering if this was possible and if so if someone could point me in the right direction on how to accomplish it.

Cooper answered 19/10, 2012 at 13:15 Comment(0)
L
3

I am attempting to display the text of the notification in the notification bar for 10 seconds instead of the standard amount of time.

If "the text of the notification in the notification bar" means the ticker text (e.g., setTicker() on your Builder), you do not control that duration.

If "the text of the notification in the notification bar" means something in the notification drawer entry, you are welcome to cancel() your notification after a period of time.

Lahnda answered 19/10, 2012 at 13:17 Comment(1)
Yes I meant the text set by setTicker() and from what I was reading and my experiences with android I didn't think it was possible to control the duration but I was wondering if someone had a workaround or perhaps I had missed something.Cooper
N
1

I am not convinced that this is a behavior users would expect (they may not have a look at the device within 10s)

Having said that, you may try to set an alarm, that fires 10s in the future, and which cancels the notification.

If you want a short notice for a user that is looking at the screen already, you may be better off with using a Toast.

Naughty answered 19/10, 2012 at 13:19 Comment(2)
I also think that a disappearing notification is a very weird concept that will confuse the users. If you want to do this use a toast, or Crouton.Unpen
Thanks for the suggestions, but I'm not sure we're on the same page. I'm not looking to delete the notification after 10 seconds. I'm only looking to keep the text from the notification visible for 10 seconds instead of the standard 3-4 seconds. Then the text would scroll off of the notification bar as normal and the icon would stay visible for the user to see. Then if someone dragged the notification bar open the notification would still be present.Cooper

© 2022 - 2024 — McMap. All rights reserved.