如何在 Android 上为单个联系人设置铃声?
如何仅将铃声应用于选定的联系人?
我找到了一种设置适用于所有联系人的默认铃声的方法,但这不是我的目标。
我希望应用程序有一个按钮(“将铃声应用于联系人”),单击该按钮时,会启动 activityForResult
显示手机上所有联系人的列表。选择联系人后,联系人活动将关闭并返回该联系人的 URI。然后应用程序需要将选定的铃声应用于该特定联系人。
通过活动显示和选择联系人的代码已经实现,并且似乎可以在应用程序上运行。
How can I apply a ringtone to only the selected contact?
I have found a way to set the default ringtone that applies to all contacts, but that is not my goal.
I want an application to have a button ("Apply ringtone to contact") that, when clicked, starts an activityForResult
displaying a list of all contacts on the phone. When a contact is selected, the contact activity closes and returns with a URI to the contact. Then the app needs to apply the selected ringtone to that specific contact.
The code for displaying and selecting contacts by an activity is already implemented and seems to work on the app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 ContactsContract.Contacts ,其中有一列
CUSTOM_RINGTONE
(这是一个读/写列!)用于此目的。此外,您可能会发现此讨论很有用(代码采用从那里)。
You can use ContactsContract.Contacts which has a column
CUSTOM_RINGTONE
(which is a read/write column!) for this purpose.Furthermore, you may find this discussion useful (code taken from there).
我知道这已经太晚了,但我在这里发帖是因为上面的一个对我不起作用
注意:我们必须为 marsh mallow 添加运行时权限,
并将所有这些权限包含在清单文件中
I know this was so late, but i'm posting here because above one not worked for me
Note: We have to add runtime permissions for marsh mallow as
and also include all these permissions in Manifest file as