Android ringtone custom ringtones

Source: Internet
Author: User

1. the following formats are supported:

64. Midi, AAC, AAC +, Amr, WAV, MP3, Real Audio, WMA, and Ogg.

2. How to Use the audio files in sdcard as ringtones:

Create a folder under the root directory of the sdcard:

Media/Audio/ringtone (generally there are three sub-folders under the audio Folder: ringtones, alarms and notifications), and then copy the ringtone to the folder.

3. How to Use code to implement custom ringtones?

Verification is also required for code implementation.

Okay, the code is implemented:

 

File K = new file ("/sdcard/Media/Audio/ringtones", "therain.pdf "); <br/> // path is/sdcard/Media/ringtone <br/> contentvalues values = new contentvalues (); <br/> values. put (mediastore. mediacolumns. data, K. getabsolutepath (); <br/> // values. put (mediastore. mediacolumns. title, "My song title"); <br/> // values. put (mediastore. mediacolumns. size, 215454); <br/> values. put (mediastore. mediacolumns. mime_type, "audio/MP3"); <br/> // values. put (mediastore. audio. media. artist, "Madonna"); <br/> // values. put (mediastore. audio. media. duration, 230); <br/> values. put (mediastore. audio. media. is_ringtone, true); <br/> values. put (mediastore. audio. media. is_notification, false); <br/> values. put (mediastore. audio. media. is_alarm, false); <br/> values. put (mediastore. audio. media. is_music, false); <br/> // insert it into the databaseuri <br/> URI uri = mediastore. audio. media. getcontenturiforpath (K. getabsolutepath (); <br/> URI newuri = getcontentresolver (). insert (Uri, values); <br/> string testring = newuri. tostring (); <br/> ringtonemanager. setactualdefaultringtoneuri (ringtone. this, ringtonemanager. type_ringtone, newuri ); 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.