Example usage for android.media RingtoneManager TYPE_NOTIFICATION

List of usage examples for android.media RingtoneManager TYPE_NOTIFICATION

Introduction

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

Prototype

int TYPE_NOTIFICATION

To view the source code for android.media RingtoneManager TYPE_NOTIFICATION.

Click Source Link

Document

Type that refers to sounds that are used for notifications.

Usage

From source file:Main.java

public static boolean isMessageRing(int type) {
    if (type == RingtoneManager.TYPE_NOTIFICATION) {
        return true;
    }//from ww w  .  j  a  va  2s.co  m
    return false;
}

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();/*  w w  w .  j av a2s. c  om*/
}

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  .  j  a  v  a2s.  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();//from   w ww .  j  a v  a  2  s .  c o m
}

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  ww  .  j ava  2 s . co  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  ww  w. j a v  a2 s  .  co  m*/
        }
    }
}

From source file:Main.java

public static void playDefaultNotification(Context context) {
    playSound(context, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
}

From source file:Main.java

public static Uri getAlarmRingtoneUri() {
    Uri alert = RingtoneManager.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);
        }//  w  w  w . j ava 2s  .  co m
    }
    return alert;
}

From source file:Main.java

/**
 * Getter for the current Default Notification Ringtone URI.
 * @param ctx//  w w  w .  ja  v a2 s.c o  m
 * @return
 */
public static Uri getDefaultNotificationRingtoneUri(Context ctx) {
    return RingtoneManager.getActualDefaultRingtoneUri(ctx, RingtoneManager.TYPE_NOTIFICATION);
}

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  w w w.j  av  a  2 s.c  o m*/
        beepTime = System.currentTimeMillis();
    } else {
        beepTime = 0;
    }

}