How to change notification sound dynamically in Android O

霸气de小男生 提交于 2019-12-07 05:11:08

问题


Recently I use notification channel to support android O. But the problem is I cannot change the sound Uri dynamically. Our app have notification sound setting which user can change app notification sound as they want. But as you know, Android now do not allow developer to update notification channel before user reinstall app. There I consider several possible solutions which is not looks good.

  1. User ringtone manager to play ringtone instead of setSound. But when user disable notification in app setting, still ringtone will not stop playing. (This will be bad user experience)

  2. Delete notification channel and create new one when user change ringtone sound. But this also looks bad because in app setting google shows the history of deleted channel info.(Actually not necessary)

Is there any good solution?


回答1:


On Android O+ devices, you should remove any notification specific settings within your app and offer a link within your settings screen to open the system's notification channel settings, where the user can adjust the sound of the notification channel directly.



来源:https://stackoverflow.com/questions/49605594/how-to-change-notification-sound-dynamically-in-android-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!