Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting ringtone from my raw folder in android

Tags:

android

I am trying to read/access an mp3 file in my Raw folder and then set it as default ringtone. But it is not able to find it.

My code is -

                Uri path = Uri.parse("android.resource://com.applenty/LearnToCount/raw/mysoundfile");
            RingtoneManager.setActualDefaultRingtoneUri(
                    getApplicationContext(), RingtoneManager.TYPE_RINGTONE,
                    path);
            Log .i("TESTT", "Ringtone Set to Resource: "+ path.toString());
            RingtoneManager.getRingtone(getApplicationContext(), path)
                    .play();

Waht is wrong in here? I have tried all sort of combination here

like image 974
nasaa Avatar asked May 29 '11 14:05

nasaa


People also ask

Where is the raw folder on Android?

The raw folder in Android is used to keep mp3, mp4, sfb files, etc. The raw folder is created inside the res folder: main/res/raw.


1 Answers

This is working for me. (remove LearnToCount)

Uri path = Uri.parse("android.resource://com.applenty/raw/mysoundfile");

And then in your manifest.

<uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission>
like image 124
rochdev Avatar answered Nov 15 '22 12:11

rochdev