get Alarm Ringtone Uri - Android Android OS

Android examples for Android OS:Alarm Information

Description

get Alarm Ringtone Uri

Demo Code


//package com.java2s;

import android.media.RingtoneManager;
import android.net.Uri;

public class Main {
    public static Uri getAlarmRingtoneUri() {
        Uri alert = RingtoneManager/*from   w ww.  j a va  2 s  . c  o m*/
                .getDefaultUri(RingtoneManager.TYPE_ALARM);
        if (alert == null) {
            // alert is null, using backup
            alert = RingtoneManager
                    .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            if (alert == null) { // I can't see this ever being null (as always
                // have a default notification) but just incase
                // alert backup is null, using 2nd backup
                alert = RingtoneManager
                        .getDefaultUri(RingtoneManager.TYPE_RINGTONE);
            }
        }
        return alert;
    }
}

Related Tutorials