I want to develop a messaging app . In this messaging app , the user can change the default sms ringtone . For this I have to show in a dialogue all sms ringtone . Whenever the user select the sms ringtone , the name of the sms ringtone will be set in a textview and the ringtone will be set as default sms ringtone . How can I do this ?
Whichever you do it. This code will surely do stuff you want!!
selsound_button.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0)
{
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
Uri currenturi = ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, 1l);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select ringtone for notifications:");
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currenturi);
startActivityForResult( intent, 999);
}
});
RingtoneManager.setActualDefaultRingtoneUri(
myActivity, RingtoneManager.TYPE_RINGTONE, currenturi);
Well Adding in your manifest file is a must
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
uri is not the name of the name of the rigntone
Ringtone ringtone = RingtoneManager.getRingtone(this, uri);
String title = ringtone.getTitle(this);
use it as convinient to you