Example usage for android.media RingtoneManager getRingtone

List of usage examples for android.media RingtoneManager getRingtone

Introduction

In this page you can find the example usage for android.media RingtoneManager getRingtone.

Prototype

public static Ringtone getRingtone(final Context context, Uri ringtoneUri) 

Source Link

Document

Returns a Ringtone for a given sound URI.

Usage

From source file:Main.java

public static Ringtone get_ringtone(Context m, Object uri) {

    return RingtoneManager.getRingtone(m, Uri.parse(uri + ""));
}

From source file:Main.java

public static String getNameOfRingtone(Context context, Uri uri) {
    Ringtone ringtone = RingtoneManager.getRingtone(context, uri);
    return ringtone.getTitle(context);
}

From source file:Main.java

public static void playDefault(Context context) {
    Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone r = RingtoneManager.getRingtone(context, notification);
    r.play();/*from   w  ww  . ja  v a2  s . com*/
}

From source file:Main.java

public static void playSound(Context context) {
    Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone r = RingtoneManager.getRingtone(context, notification);
    r.play();//from   w w w . ja v a  2  s .  c  o  m
}

From source file:Main.java

public static void playDefaultNotificationSound(Context context) {
    Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone r = RingtoneManager.getRingtone(context, notification);
    r.play();/*  w w w. jav a  2s. com*/
}

From source file:Main.java

public static void playNotification(Context context) {
    Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone r = RingtoneManager.getRingtone(context, notification);
    r.play();//from w w  w. j a  v a2  s  .  c  o m
}

From source file:Main.java

public static void playNotificationSound(Context context) {
    Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    if (uri != null) {
        Ringtone rt = RingtoneManager.getRingtone(context, uri);
        if (rt != null) {
            rt.setStreamType(AudioManager.STREAM_NOTIFICATION);
            rt.play();//from  www .  j a v  a  2 s . c  o m
        }
    }
}

From source file:Main.java

public static void ring(Context context) {
    if ((System.currentTimeMillis() - beepTime) > 6 * 1000) {
        Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        Ringtone r = RingtoneManager.getRingtone(context.getApplicationContext(), notification);
        r.play();//from   www.j  a  v  a2s .  co m
        beepTime = System.currentTimeMillis();
    } else {
        beepTime = 0;
    }

}

From source file:Main.java

/**
 * Getter for the current Default Notification Ringtone object.
 * @param ctx/*from w w  w . j a v a  2  s  . c om*/
 * @return The Ringtone, or null if there isn't one set.
 */
public static Ringtone getDefaultNotificationRingtone(Context ctx) {
    Uri currentNotificationRingtoneUri = getDefaultNotificationRingtoneUri(ctx);

    if (currentNotificationRingtoneUri == null) {
        return null;
    }

    Ringtone r = RingtoneManager.getRingtone(ctx, currentNotificationRingtoneUri);

    return r;
}

From source file:Main.java

public static void playRingtone(Context context) {
    //       Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    //        if(alert == null){
    //            alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
    //        }/*from w  w w .j a  v  a  2  s  .c  om*/
    //       Ringtone r = RingtoneManager.getRingtone(context, alert);
    //       r.play();

    Uri path = Uri.parse("android.resource://" + context.getPackageName() + "/raw/waterdrop4");
    //       RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE,path);
    RingtoneManager.getRingtone(context, path).play();
}