List of usage examples for android.app Notification DEFAULT_ALL
int DEFAULT_ALL
To view the source code for android.app Notification DEFAULT_ALL.
Click Source Link
From source file:com.commonsware.android.webserver.WebServerService.java
private void foregroundify() { NotificationCompat.Builder b = new NotificationCompat.Builder(this); Intent iReceiver = new Intent(this, StopReceiver.class); PendingIntent piReceiver = PendingIntent.getBroadcast(this, 0, iReceiver, 0); b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL); buildForegroundNotification(b);/*from w ww . j ava2 s . c om*/ b.addAction(R.drawable.ic_stop_white_24dp, getString(R.string.notify_stop), piReceiver); startForeground(NOTIFY_ID, b.build()); }
From source file:conversandroid.cookingnotifications.MainActivity.java
/** * Notification with an action: spoken input */// w ww. j a va 2 s .c om private void showVoiceNotification(boolean grammar) { int notificationId = 3; NotificationCompat.Action action; if (grammar) action = getGrammarAction(); else action = getVoiceAction(); //Building notification layout NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.cook).setContentTitle("New recipe") .setContentText("There is a tasty new recipe").setDefaults(Notification.DEFAULT_ALL) //Beware that without some default behaviours //the notification may not show up in the wearable .setAutoCancel(true).extend(new NotificationCompat.WearableExtender().addAction(action)); //Creating an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); // Building the notification and issuing it with the notification manager notificationManager.notify(notificationId, notificationBuilder.build()); }
From source file:tv.acfun.a63.service.PushService.java
private void showNotification(Comment c) { Intent i = new Intent(this, MentionActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, i, Intent.FLAG_ACTIVITY_NEW_TASK); Notification noti = new NotificationCompat.Builder(this).setContentTitle(c.userName + "??") .setContentText(c.content).setWhen(System.currentTimeMillis()).setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL).setContentIntent(pendingIntent) .setSmallIcon(R.drawable.notify_chat).build(); mManager.notify(0, noti);//from ww w.j a v a 2s . c o m }
From source file:com.kratav.tinySurprise.notification.MyGcmListenerService.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private Notification notificationType1() { Bitmap smallIconBitmap = getMeBitmap(smallIcon); if (smallIconBitmap == null) return null; Bitmap largeImageBitmap = getMeBitmap(largeIcon); if (largeImageBitmap == null) return null; NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setContentTitle(title) .setTicker(title).setSubText(subtitle).setSmallIcon(R.drawable.ic_launcher) .setLargeIcon(smallIconBitmap).setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE permission .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(largeImageBitmap)) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); builder.setContentIntent(pendingIntent); return builder.build(); }
From source file:es.usc.citius.servando.calendula.activities.ReminderNotification.java
private static Notification buildNotification(Context context, NotificationOptions options) { Resources res = context.getResources(); final NotificationCompat.Builder builder = new NotificationCompat.Builder(context) // Set appropriate defaults for the notification light, sound, and vibration. .setDefaults(Notification.DEFAULT_ALL) // Set required fields, including the small icon, the notification title, and text. .setSmallIcon(R.drawable.ic_pill_small).setContentTitle(options.title).setContentText(options.text) .setPriority(//w w w . j a v a 2 s .c om options.insistent ? NotificationCompat.PRIORITY_MAX : NotificationCompat.PRIORITY_DEFAULT) // Provide a large icon, shown with the notification in the // notification drawer on devices running Android 3.0 or later. .setLargeIcon(options.picture) // Set ticker text (preview) information for this notification. .setTicker(options.ticker) // Show a number. This is useful when stacking notifications of a single type. .setNumber(options.notificationNumber).setWhen(options.when) // Set the pending intent to be initiated when the user touches the notification. .setContentIntent(options.defaultIntent) //.setOngoing(true) // add delay button .addAction(R.drawable.ic_history_white_24dp, res.getString(R.string.notification_delay), options.delayIntent) .addAction(R.drawable.ic_alarm_off_white_24dp, res.getString(R.string.notification_cancel_now), options.cancelIntent) // Show an expanded list of items on devices running Android 4.1 // or later. .setStyle(options.style) //.setLights(0x00ff0000, 500, 1000) .setPriority(Notification.PRIORITY_DEFAULT) .setVibrate(new long[] { 1000, 200, 500, 200, 100, 200, 1000 }).setSound(options.ringtone) // Automatically dismiss the notification when it is touched. .setAutoCancel(true); if (options.insistent) { builder.setFullScreenIntent(options.defaultIntent, true); } Notification n = builder.build(); n.defaults = 0; n.ledARGB = 0x00ffa500; n.ledOnMS = 1000; n.ledOffMS = 2000; if (options.insistent) { n.flags |= Notification.FLAG_INSISTENT; } return n; }
From source file:com.granita.tasks.notification.NotificationActionUtils.java
public static void sendStartNotification(Context context, String title, Uri taskUri, int notificationId, long startDate, boolean startAllDay, boolean silent) { String startString = ""; if (startAllDay) { startString = context.getString(R.string.notification_task_start_today); } else {//from www. ja va 2s . co m startString = context.getString(R.string.notification_task_start_date, new DateFormatter(context) .format(makeTime(startDate, startAllDay), DateFormatContext.NOTIFICATION_VIEW)); } NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); // build notification NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_notification) .setContentTitle(context.getString(R.string.notification_task_start_title, title)) .setContentText(startString); // dismisses the notification on click mBuilder.setAutoCancel(true); // set status bar test mBuilder.setTicker(title); // enable light, sound and vibration if (silent) { mBuilder.setDefaults(0); } else { mBuilder.setDefaults(Notification.DEFAULT_ALL); } // set notification time // set displayed time if (startAllDay) { Time now = new Time(); now.setToNow(); now.set(0, 0, 0, now.monthDay, now.month, now.year); mBuilder.setWhen(now.toMillis(true)); } else { mBuilder.setWhen(startDate); } // add actions if (android.os.Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) { NotificationAction completeAction = new NotificationAction( NotificationActionIntentService.ACTION_COMPLETE, R.string.notification_action_completed, notificationId, taskUri, startDate); mBuilder.addAction(NotificationActionIntentService.getCompleteAction(context, NotificationActionUtils.getNotificationActionPendingIntent(context, completeAction))); } // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(Intent.ACTION_VIEW); resultIntent.setData(taskUri); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); notificationManager.notify(notificationId, mBuilder.build()); }
From source file:foam.zizim.android.BoskoiService.java
private void showNotification(String tickerText) { // This is what should be launched if the user selects our notification. Intent baseIntent = new Intent(this, IncidentsTab.class); baseIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, baseIntent, 0); // choose the ticker text newBoskoiReportNotification = new Notification(R.drawable.favicon, tickerText, System.currentTimeMillis()); newBoskoiReportNotification.contentIntent = contentIntent; newBoskoiReportNotification.flags = Notification.FLAG_AUTO_CANCEL; newBoskoiReportNotification.defaults = Notification.DEFAULT_ALL; newBoskoiReportNotification.setLatestEventInfo(this, TAG, tickerText, contentIntent); if (ringtone) { // set the ringer Uri ringURI = Uri.fromFile(new File("/system/media/audio/ringtones/ringer.mp3")); newBoskoiReportNotification.sound = ringURI; }/*from www . j a va 2s . c o m*/ if (vibrate) { double vibrateLength = 100 * Math.exp(0.53 * 20); long[] vibrate = new long[] { 100, 100, (long) vibrateLength }; newBoskoiReportNotification.vibrate = vibrate; if (flashLed) { int color = Color.BLUE; newBoskoiReportNotification.ledARGB = color; } newBoskoiReportNotification.ledOffMS = (int) vibrateLength; newBoskoiReportNotification.ledOnMS = (int) vibrateLength; newBoskoiReportNotification.flags = newBoskoiReportNotification.flags | Notification.FLAG_SHOW_LIGHTS; } mNotificationManager.notify(NOTIFICATION_ID, newBoskoiReportNotification); }
From source file:com.nbempire.dentalnavarra.component.service.RemembersService.java
private void showNotification(String title, String text, Remember remember) { Log.d(TAG, "Building notification..."); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification).setContentTitle(title).setContentText(text) .setAutoCancel(true);/* w w w. j a va 2 s. co m*/ // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(this, DentalNavarraActivity.class); if (remember != null) { Log.i(TAG, "Adding extra parameter to notification result intent, message: " + remember.getMessage()); resultIntent.putExtra(NOTIFICATION_INTENT_PARAMETER_MESSAGE, remember.getMessage()); Log.i(TAG, "Adding extra parameter to notification result intent, meetingDate: " + remember.getMeetingDate()); resultIntent.putExtra(NOTIFICATION_INTENT_PARAMETER_MEETING_DATE, remember.getMeetingDate()); Log.i(TAG, "Adding extra parameter to notification result intent, treatments: " + remember.getTreatments()); resultIntent.putExtra(NOTIFICATION_INTENT_PARAMETER_TREATMENTS, remember.getTreatments()); } // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(DentalNavarraActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); Notification notification = mBuilder.build(); notification.defaults |= Notification.DEFAULT_ALL; NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. // TODO : Functionality : Should I unhard-code this ID? mNotificationManager.notify(44, notification); Log.d(TAG, "Notification added to status bar: " + text); }
From source file:dentex.youtube.downloader.utils.Utils.java
public static void setNotificationDefaults(NotificationCompat.Builder aBuilder) { String def = YTD.settings.getString("notification_defaults", "0"); if (aBuilder != null) { if (def.equals("0")) { aBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); }//from w w w. j av a 2 s . com if (def.equals("1")) { aBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS); } if (def.equals("2")) { aBuilder.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE); } if (def.equals("3")) { aBuilder.setDefaults(Notification.DEFAULT_ALL); } if (def.equals("4")) { aBuilder.setDefaults(Notification.DEFAULT_SOUND); } if (def.equals("5")) { aBuilder.setDefaults(Notification.DEFAULT_VIBRATE); } if (def.equals("6")) { aBuilder.setDefaults(Notification.DEFAULT_LIGHTS); } if (def.equals("7")) { // nothing... } } }
From source file:org.dmfs.tasks.notification.NotificationActionUtils.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void sendStartNotification(Context context, String title, Uri taskUri, int notificationId, long startDate, boolean startAllDay, boolean silent) { String startString = ""; if (startAllDay) { startString = context.getString(R.string.notification_task_start_today); } else {//from ww w. ja v a 2 s . c o m startString = context.getString(R.string.notification_task_start_date, formatTime(context, makeTime(startDate, startAllDay))); } NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); // build notification NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_notification) .setContentTitle(context.getString(R.string.notification_task_start_title, title)) .setContentText(startString); // color mBuilder.setColor(context.getResources().getColor(R.color.colorPrimary)); // dismisses the notification on click mBuilder.setAutoCancel(true); // set high priority to display heads-up notification if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { mBuilder.setPriority(Notification.PRIORITY_HIGH); } // set status bar test mBuilder.setTicker(title); // enable light, sound and vibration if (silent) { mBuilder.setDefaults(0); } else { mBuilder.setDefaults(Notification.DEFAULT_ALL); } // set notification time // set displayed time if (startAllDay) { Time now = new Time(); now.setToNow(); now.set(0, 0, 0, now.monthDay, now.month, now.year); mBuilder.setWhen(now.toMillis(true)); } else { mBuilder.setWhen(startDate); } // add actions if (android.os.Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) { NotificationAction completeAction = new NotificationAction(NotificationUpdaterService.ACTION_COMPLETE, R.string.notification_action_completed, notificationId, taskUri, startDate); mBuilder.addAction(NotificationUpdaterService.getCompleteAction(context, NotificationActionUtils.getNotificationActionPendingIntent(context, completeAction))); } // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(Intent.ACTION_VIEW); resultIntent.setData(taskUri); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); notificationManager.notify(notificationId, mBuilder.build()); }