Mark M. |
how can I help you today?
|
Milan |
Hello Mark. One question, regarding updating in progress notification. Consider next scenario: Message (file transfer) is received, notification is fired with vibration & ringtone played by notification itself. Once it is accepted, progress should be shown on notification, so notification is updated every x unit of time. Notification should not play vibration&ringtone each time it is updated. Keeping in mind we are speaking about 8 and above OS version, is there any other way to have that process silent except creating a new silent channel?
|
Mark M. |
you should be able to just use setOnlyAlertOnce(true) on your NotificationCompat.Builder
|
Milan |
only on builder... hm, I didn't tried that
|
Mark M. |
this will put a flag on the notification that will cause it to only do the "alert" portion (ringtone, vibration pattern) if the notification is not already on-screen
|
Mark M. |
I just added this to one of the book samples, for the next update, and it worked fine, without having to create a separate channel
|
Milan |
I thought channel is responsible for it. Will test in a few minutes
|
Milan |
And you are supposed to keep notification object cached? To not build it again (although with same notification ID)
|
Mark M. |
I cached the Builder, IIRC
|
Mark M. |
yes, I call builder.setProgress() on the same Builder instance, then have it build() a new Notification to use with NotificationManager
|
Mark M. |
where I originally set up the Builder with setOnlyAlertOnce(true)
|
Mark M. |
that's the sample service -- the only thing missing is the setOnlyAlertOnce(true) call, which I added to buildForeground() in the upcoming edition
|
Mark M. |
and that's a wrap for today's chat
|
Mark M. |
the transcript will appear at https://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is Thursday at the same time -- 9am US Eastern
|