-1

I have a listview with sounds items. I need, when a item is long press es, set it as ringtone or notification from raw sound of my app. How can I do this? Thanks

user3437592
  • 59
  • 3
  • 9

1 Answers1

0

Answer from my other post here...

Set ringtone from res/raw folder

You cannot set the ringtone from resource.

RingtoneManager.setActualDefaultRingtoneUri expects the ringtone file in the device and the Uri should be from content resolver.

    File ring = new File("pathOfYourFile");
     Uri path = MediaStore.Audio.Media.getContentUriForPath(ring.getAbsolutePath());

RingtoneManager.setActualDefaultRingtoneUri(getApplicationContext(), RingtoneManager.TYPE_RINGTONE,path);

Also make sure to add permission

Community
  • 1
  • 1
Libin
  • 16,967
  • 7
  • 61
  • 83