本文介绍了如何在 Android O 中动态更改通知声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我使用通知渠道来支持android O.但问题是我无法动态更改声音 Uri.我们的应用程序具有通知声音设置,用户可以根据需要更改应用程序通知声音.但如您所知,Android 现在不允许开发人员在用户重新安装应用程序之前更新通知渠道.在那里我考虑了几种可能的解决方案,但看起来不太好.

  1. 用户铃声管理器播放铃声而不是 setSound.但是当用户在应用设置中禁用通知时,仍然不会停止播放铃声.(这将是糟糕的用户体验)

  2. 当用户更改铃声时删除通知频道并创建新频道.但这看起来也很糟糕,因为在应用设置中,谷歌会显示已删除频道信息的历史记录.(实际上没有必要)

有什么好的解决办法吗?

解决方案

在 Android O+ 设备上,您应该删除应用中的所有通知特定设置,并在设置屏幕中提供一个链接到 打开系统的通知频道设置,用户可以直接调整通知频道的声音.>

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?

解决方案

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.

这篇关于如何在 Android O 中动态更改通知声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-21 00:51