0

I'm new to android studio and I was wondering if there was any method wherein you could allow the user to set the notification tone. The notifications are generated using AlarmManager.

1 Answers1

0

Yes of course! Put your songs files in Res\raw\. Files Names should always be lowercase .

To allow the user set custom notification tone, you may need a listview or recyclerview where you list all songs you've put on raw folder. The user can listen to the tone and choose it.

Based on user choice you set the notification tone using this code in your alarm manager:

Notification notification = builder.build();
notification.sound = Uri.parse("android.resource://"
            + context.getPackageName() + "/" + R.raw.siren); //if you have a file siren.mp3 in raw folder

Source : https://stackoverflow.com/a/17993700/12802591

To know what song the user has chosen, you need to implement OnClick method and retreive the song name and then pass it by intent to the alarm manager.

I recommend seeing tutorials on Recyclerview, ListView and other types of Views and Layouts. You should know available tools, how they works to solve any problem you have.

-RecyclerView Tutorial : https://www.youtube.com/watch?v=bhhs4bwYyhc

-ListView Tutorial : https://www.youtube.com/watch?v=SLFrwl1hFcw

(check the previous parts for better understanding)

Let me know if it solves your problem. Thanks!

Community
  • 1
  • 1
choubari
  • 31
  • 5