Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set default alarm sound programatically Android

Tags:

android

alarm

I've been trying to define the default alarm sound but with no success! I can sucessfully change the ringtone and the notification sound but the alarm doesn't change at all... I'm using this code for the alarm:

RingtoneManager.setActualDefaultRingtoneUri(getActivity(), RingtoneManager.TYPE_ALARM, Uri.parse(uri+"/"+id));

Many thanks!

like image 526
user1782638 Avatar asked Nov 26 '25 13:11

user1782638


1 Answers

Try this

 try {
            RingtoneManager.setActualDefaultRingtoneUri(getContext(),
                    RingtoneManager.TYPE_ALARM, newUri);
            Settings.System.putString(mCr, Settings.System.ALARM_ALERT,
                    newUri.toString());
            Toast.makeText(getContext(), "Done", Toast.LENGTH_SHORT).show();

        } catch (Throwable t) {

        }
like image 73
Rahul Avatar answered Nov 28 '25 02:11

Rahul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!