List of usage examples for android.media RingtoneManager getDefaultUri
public static Uri getDefaultUri(int type)
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); }/*from ww w .j a va 2 s.co m*/ } return alert; }
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 w w .j a v a 2 s . c o m }
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 ww w.ja va 2s . 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 w w. jav a 2s . 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 ww w . j a v a2 s .com*/ }
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 w w w.j a v a 2 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 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; } }
From source file:Main.java
public static NotificationCompat.Builder buildNotification(Context context, Class<?> cls, int icon, int title, String text) {/*from w w w. j ava 2s. com*/ Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setSmallIcon(icon) .setContentTitle(context.getString(title)).setContentText(text).setAutoCancel(true).setSound(sound) .setTicker(text); Intent intent = new Intent(context, cls); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context).addParentStack(cls).addNextIntent(intent); PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pendingIntent); return builder; }
From source file:Main.java
public static void showNotification(long id, String titleString, String messageString, int iconResId, Context context, Class<?> className) { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setSmallIcon(iconResId) .setContentTitle(titleString).setStyle(new NotificationCompat.BigTextStyle().bigText(messageString)) .setContentText(messageString); Intent intent = new Intent(context, className); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(className); stackBuilder.addNextIntent(intent);//from w w w. j ava 2 s .co m PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = mBuilder.build(); notification.flags = Notification.FLAG_AUTO_CANCEL; mNotificationManager.notify((int) id, notification); }