Set custom ringtone function for Android App

Because there is a demand to add ringtones and play them in their own app, but most of the relevant materials consulted on the Internet are to teach people how to set the functions of mobile phone system such as mobile phone incoming call and alarm clock, so this article is used as a record.

1、 The general content of this article is

1. Call the system ringtone interface to select the ringtone;

2. Play the selected ringtone;

3. When calling the system ringtone interface again, the previously selected ringtone is checked by default;

4. Very important authorities should be added;

2、 Illustration

The interface code is very simple, as the name suggests.

3、 Partial logic code implementation

① Call the system ringtone interface to transfer the current ringtone data and select a new ringtone

② Play the currently selected ringtone

So far, you think it's over? In fact, it's still a very important step. You need to add corresponding permissions:

If the above permissions are not added, the possible problems are that some ringtones can be played and some ringtones cannot be played (music song files cannot be played). From the log, all ringtones, including music songs, have URI. Since they all have URI, why can't they be played? In general, the possibility of errors in the mobile phone system is very small. How can such a big error come out? Because all music and song files cannot be played, and these files are placed on SD card, that is, external files, you need to add corresponding permissions such as external file access.

Finally, the complete code can be stamped here > >: click the open link

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>