开发者

How do I perform an action when an Android Notification is complete?

I have a service that starts a broadcastReceiver to listen for an SMS. If the specific SMS is received it sets the notification volume to maximum and fires a notification.

How can I return the volume to the previous开发者_JS百科 setting AFTER the notification has completed?


You can't do this directly, and as a workaround you can try to get the current notification sound's length, wait for that specific period, and then change the volume. I don't think it's very reliable though ...


There is no notion of a "notification has completed".

If you mean "when the sound for my notification has completed", you know how long the sound is. Use AlarmManager to schedule an alarm to get notified after that amount of time has elapsed (perhaps plus a second or two, to be sure), and then change the volume back when that alarm goes off.

Or, better yet, don't mess with the volume in the first place.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜