0

I'm using this code to set a sound as a notification message after I saved the sound:

---------------after saving---------------

 File k = new File("/sdcard/Bizzsound/", "b1.mp3");
 ContentValues values = new ContentValues();
 values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
 values.put(MediaStore.MediaColumns.TITLE, "sound1");                             
 values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
 values.put(AudioColumns.ARTIST, "artist");
 values.put(AudioColumns.IS_RINGTONE, true);
 values.put(AudioColumns.IS_NOTIFICATION, true);
 values.put(AudioColumns.IS_ALARM, true);
 values.put(AudioColumns.IS_MUSIC, false);
 Uri uri = MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath());
 Uri newUri = getContentResolver().insert(uri, values);
 RingtoneManager.setActualDefaultRingtoneUri(menu.this,RingtoneManager.TYPE_NOTIFICATION,
                         newUri);

now i want to set the notification of sound message as default

thanks in advance

Gapp Aiello
  • 182
  • 1
  • 15
  • This should work but if the app your trying to test uses something else than default this wont work. It all comes down to manufacture implementation of apps. – Warpzit Dec 08 '13 at 18:29
  • the code works perfectly, but for message notification only works if the ringer is set to default – Gapp Aiello Dec 08 '13 at 18:32

1 Answers1

1

I guess you can use the following

RingtoneManager.setActualDefaultRingtoneUri(this, RingtoneManager.TYPE_NOTIFICATION,      uriObjectofYourAudioFile);

You would also have to give the following permission

<uses-permission android:name="android.permission.WRITE_SETTINGS" ></uses-permission>
Antrromet
  • 15,294
  • 10
  • 60
  • 75