H
H
HugC2013-01-21 09:49:02
Android
HugC, 2013-01-21 09:49:02

How to set MP3 as a ringtone from the application?

There is an Android application in HTML5, several dozen MP3 files are “hardwired” in it (the application is assembled from HTML into APK in Eclipse).
How to set MP3 as ringtone from the application?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2013-01-25
@Evgenym

Assuming that the ringtone does not require a high quality melody, then I would simply connect the device to a computer or other device that can record incoming sound and simply record it.

Z
ZZnOB, 2013-01-27
@ZZnOB

For example so.

ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, <<asbolutePathToYourAudioFileHere>>);
values.put(MediaStore.MediaColumns.TITLE, "<<yourRingToneNameHere>>");
values.put(MediaStore.MediaColumns.SIZE, k);
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mpeg");    // assuming it's an mpeg, of course
values.put(MediaStore.Audio.Media.ARTIST, "<<yourArtistNameHere>>");
// values.put(MediaStore.Audio.Media.DURATION, duration);  // doesn't appear to be necessary if you don't know
values.put(MediaStore.Audio.Media.IS_RINGTONE, true);

Uri uri = MediaStore.Audio.Media.getContentUriForPath(outPath);  
Uri newUri = getContentResolver().insert(uri, values);

RingtoneManager.setActualDefaultRingtoneUri(
                                <<MyActivity>>.this,
                                RingtoneManager.TYPE_RINGTONE,
                                newUri);

Found here stackoverflow.com/a/1287415

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question