List of usage examples for android.media RingtoneManager TYPE_NOTIFICATION
int TYPE_NOTIFICATION
To view the source code for android.media RingtoneManager TYPE_NOTIFICATION.
Click Source Link
From source file:Main.java
public static void pickRing(Activity activity) { Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone"); if (mRingUri != null) { intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, mRingUri); } else {// ww w . ja v a 2 s .co m intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null); } activity.startActivityForResult(intent, RESULT_PICK_RING); }
From source file:Main.java
/** * Set the Default Notification Ringtone to the given URI. * @param ctx//from w w w. ja va 2 s .com * @param uri URI of a row in MediaStore */ public static void setDefaultNotificationRingtone(Context ctx, Uri uri) { RingtoneManager.setActualDefaultRingtoneUri(ctx, RingtoneManager.TYPE_NOTIFICATION, uri); }
From source file:Main.java
/** * Gets a specific system string based on a ringtone type * @param type The ringtone type/* w w w . j av a 2 s . co m*/ * @return A string representing the ringtone type */ private static String getStringByType(int type) { switch (type) { case RingtoneManager.TYPE_ALARM: return Settings.System.ALARM_ALERT; case RingtoneManager.TYPE_NOTIFICATION: return Settings.System.NOTIFICATION_SOUND; case RingtoneManager.TYPE_RINGTONE: return Settings.System.RINGTONE; default: return null; } }
From source file:Main.java
public static NotificationCompat.Builder buildNotification(Context context, Class<?> cls, int icon, int title, String text) {// w ww . j a v a 2 s . c o m 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 av a 2s.c om 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); }
From source file:com.github.bettehem.androidtools.notification.CustomNotification.java
public static CustomNotification make(Context context, int iconId, String title, String message, Intent intent, boolean isPersistent, boolean dismissOnTap) { NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context); notificationBuilder.setSmallIcon(iconId); notificationBuilder.setContentTitle(title); notificationBuilder.setContentText(message); notificationBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); notificationBuilder.build();/*w ww . ja v a 2 s . c o m*/ PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); notificationBuilder.setContentIntent(resultPendingIntent); notificationBuilder.setOngoing(isPersistent); notificationBuilder.setAutoCancel(dismissOnTap); return new CustomNotification(context, notificationBuilder); }
From source file:GCMService.java
private void sendNotification(String message) { Log.i("GCMService", "sendNotification()"); Uri notificationSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("GCM Message").setContentText(message) .setSound(notificationSoundUri).setLights(Color.BLUE, 500, 500); NotificationManager notificationManager = (NotificationManager) getApplicationContext() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build()); }
From source file:MainActivity.java
public void clickLightsActionSound(View view) { NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); Uri notificationSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("LightsActionSoundRedux") .setContentText("Lights, Action & Sound").setSound(notificationSoundUri) .setLights(Color.BLUE, 500, 500).setVibrate(new long[] { 250, 500, 250, 500, 250, 500 }); notificationManager.notify(0, notificationBuilder.build()); }
From source file:Main.java
/** * Get an alarm sound. Try for an alarm. If none set, try notification, otherwise, ringtone. * * @return Alarm media uri// w w w .j a va 2 s . c om */ private static Uri getAlarmUri() { Uri alarm = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); if (alarm == null) { alarm = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); if (alarm == null) { alarm = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); } } return alarm; }
From source file:com.contactmanager.home.assignmentreminder.AlarmReceiver.java
@Override public void onReceive(final Context context, Intent intent) { //this will update the UI with message TimeReminder inst = TimeReminder.instance(); inst.setAlarmText("Alarm!!! Assignment Start"); //this will sound the alarm tone //this will sound the alarm once, if you wish to //raise alarm in loop continuously then use MediaPlayer and setLooping(true) Uri alarmUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); if (alarmUri == null) { alarmUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); }/*from www . ja va 2 s .com*/ mRingtone = RingtoneManager.getRingtone(context, alarmUri); mRingtone.play(); //this will send a notification message ComponentName comp = new ComponentName(context.getPackageName(), AlarmService.class.getName()); startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK); }