Android Set Ringtone Software Doesn't Work

This is the code that I use 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 melody plays perfectly in the application when I play using the getRingtone method. But it does not play when a call is received, and in the settings menu Sound-> Sound-> Phone it appears as Unknown Ringtone.

I use Galaxy s2 as a device for testing, and the audio files are in the raw folder in res. They are in mp3 format. Os ICS Version

Any help would be greatly appreciated. thanks in advance

+1
source share

All Articles