2

This is code that I am using to set the ringtone programmatically in my android application

Uri uri=Uri.parse("android.resource://"+getPackageName()+"/raw/do_you_wanna_know_why_i_use_a_knife");
RingtoneManager manager=new RingtoneManager(NatureSounds_FinalBuildActivity.this);
manager.setActualDefaultRingtoneUri(getApplicationContext(), RingtoneManager.TYPE_RINGTONE,uri);
RingtoneManager.getRingtone(getApplicationContext(), uri).play();

The ringtone plays perfectly in the application when I play using getRingtone method. But it doesn't play when a call is received and in the Settings->Sound->Phone ringtone it shows as Unknown Ringtone.

I am using Galaxy s2 as the device to test and the sound files are located in the raw folder in res. They are of mp3 format. Os Version is ICS

Cœur
  • 37,241
  • 25
  • 195
  • 267
Tuhin Bhatt
  • 362
  • 2
  • 7
  • 19
  • 1
    Sorry for that but if i add the extension than i am getting the error failed to open ringtone and the app crashes – Tuhin Bhatt Nov 11 '12 at 16:22

0 Answers0