List of usage examples for android.app Notification DEFAULT_LIGHTS
int DEFAULT_LIGHTS
To view the source code for android.app Notification DEFAULT_LIGHTS.
Click Source Link
From source file:edu.umich.si.inteco.minuku.manager.MinukuNotificationManager.java
private Notification buildNotificationForNotificationEvent(ShowNotificationEvent aShowNotificationEvent, Integer id) {//from w ww . j a va2 s .c o m if (aShowNotificationEvent.getCreationTimeMs() == 0) { aShowNotificationEvent.setCreationTimeMs(new Date().getTime()); } Intent launchIntent = new Intent(this, aShowNotificationEvent.getViewToShow()); for (Map.Entry<String, String> entry : aShowNotificationEvent.getParams().entrySet()) { launchIntent.putExtra(entry.getKey(), entry.getValue()); } launchIntent.putExtra(Constants.TAPPED_NOTIFICATION_ID_KEY, id.toString()); //adding extra stuff to signify from notification code //launchIntent.putExtra("STARTED_FROM", "notification"); //keep this /*TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(aShowNotificationEvent.getViewToShow()); stackBuilder.addNextIntent(launchIntent);*/ //keep this PendingIntent pIntent = PendingIntent.getActivity(this, 0, launchIntent, PendingIntent.FLAG_UPDATE_CURRENT); //keep this /*PendingIntent pIntent = TaskStackBuilder.create(this) .addParentStack(aShowNotificationEvent.getViewToShow()) .addNextIntent(launchIntent) .getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT);*/ // PendingIntent.getActivity(this, // 0, launchIntent, PendingIntent.FLAG_CANCEL_CURRENT); Notification n = new Notification.Builder(this).setContentTitle(aShowNotificationEvent.getTitle()) .setContentIntent(pIntent).setContentText(aShowNotificationEvent.getMessage()) .setSmallIcon(aShowNotificationEvent.getIconID()).setAutoCancel(true).build(); n.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL; return n; }
From source file:fr.vassela.acrrd.notifier.TelephoneCallNotifier.java
public void displayCompatNotification(Context context, String ticker, String contentTitle, String contentText, boolean autoCancel, boolean ongoingEvent, boolean activateEvent) { try {// www . jav a 2 s. c o m SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean isPreferencesNotificationsActivated = sharedPreferences .getBoolean("preferences_notifications_activate", false); boolean isPreferencesNotificationsSoundActivated = sharedPreferences .getBoolean("preferences_notifications_sound_activate", false); boolean isPreferencesNotificationsVibrateActivated = sharedPreferences .getBoolean("preferences_notifications_vibrate_activate", false); boolean isPreferencesNotificationsLedActivated = sharedPreferences .getBoolean("preferences_notifications_led_activate", false); if (isPreferencesNotificationsActivated == true) { long notificationWhen = System.currentTimeMillis(); int notificationDefaults = 0; Intent intent; if (ongoingEvent == true) { intent = new Intent(context, Main.class); intent.putExtra("setCurrentTab", "home"); } else { intent = new Intent(SHOW_RECORDS); } PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notificationCompatBuilder = new NotificationCompat.Builder(context); if (ongoingEvent == false) { notificationCompatBuilder.setWhen(notificationWhen); } if (isPreferencesNotificationsSoundActivated == true) { notificationDefaults = notificationDefaults | Notification.DEFAULT_SOUND; } if (isPreferencesNotificationsVibrateActivated == true) { notificationDefaults = notificationDefaults | Notification.DEFAULT_VIBRATE; } if (isPreferencesNotificationsLedActivated == true) { notificationDefaults = notificationDefaults | Notification.DEFAULT_LIGHTS; } if (ongoingEvent == false) { notificationCompatBuilder.setDefaults(notificationDefaults); } if (activateEvent == true) { notificationCompatBuilder.setSmallIcon(R.drawable.presence_audio_online); } else { notificationCompatBuilder.setSmallIcon(R.drawable.presence_audio_busy); } if (ongoingEvent == false) { notificationCompatBuilder.setTicker(ticker); } notificationCompatBuilder.setContentTitle(contentTitle); notificationCompatBuilder.setContentText(contentText); notificationCompatBuilder.setContentIntent(pendingIntent); notificationCompatBuilder.setAutoCancel(autoCancel); notificationCompatBuilder.setOngoing(ongoingEvent); Notification notification = notificationCompatBuilder.build(); if (ongoingEvent == true) { notificationManager.notify(getOngoingNotificationId(), notification); } else { notificationManager.notify(getNotificationId(), notification); } } } catch (Exception e) { Log.w("TelephoneCallNotifier", "displayCompatNotification : " + context.getApplicationContext() .getString(R.string.log_telephone_call_notifier_error_display_notification) + " : " + e); databaseManager.insertLog(context.getApplicationContext(), "" + context.getApplicationContext() .getString(R.string.log_telephone_call_notifier_error_display_notification), new Date().getTime(), 2, false); } }
From source file:com.snappy.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *///from ww w. j a va2 s. c o m private void generateNotification(Context context, String message, String fromName, Bundle pushExtras, String body) { db = new LocalDB(context); List<LocalMessage> myMessages = db.getAllMessages(); // Open a new activity called GCMMessageView Intent intento = new Intent(this, SplashScreenActivity.class); intento.replaceExtras(pushExtras); // Pass data to the new activity intento.putExtra(Const.PUSH_INTENT, true); intento.setAction(Long.toString(System.currentTimeMillis())); intento.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_FROM_BACKGROUND | Intent.FLAG_ACTIVITY_TASK_ON_HOME); // Starts the activity on notification click PendingIntent pIntent = PendingIntent.getActivity(this, 0, intento, PendingIntent.FLAG_UPDATE_CURRENT); // Create the notification with a notification builder NotificationCompat.Builder notification = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.icon_notification).setWhen(System.currentTimeMillis()) .setContentTitle(myMessages.size() + " " + this.getString(R.string.push_new_message_message)) .setStyle(new NotificationCompat.BigTextStyle().bigText("Mas mensajes")).setAutoCancel(true) .setDefaults( Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS) .setContentText(body).setContentIntent(pIntent); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); inboxStyle.setBigContentTitle(myMessages.size() + " " + this.getString(R.string.push_new_message_message)); for (int i = 0; i < myMessages.size(); i++) { inboxStyle.addLine(myMessages.get(i).getMessage()); } notification.setStyle(inboxStyle); // Remove the notification on click //notification.flags |= Notification.FLAG_AUTO_CANCEL; //notification.defaults |= Notification.DEFAULT_VIBRATE; //notification.defaults |= Notification.DEFAULT_SOUND; //notification.defaults |= Notification.DEFAULT_LIGHTS; NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); manager.notify(R.string.app_name, notification.build()); { // Wake Android Device when notification received PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); final PowerManager.WakeLock mWakelock = pm .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "GCM_PUSH"); mWakelock.acquire(); // Timer before putting Android Device to sleep mode. Timer timer = new Timer(); TimerTask task = new TimerTask() { public void run() { mWakelock.release(); } }; timer.schedule(task, 5000); } }
From source file:gov.wa.wsdot.android.wsdot.service.MyFirebaseMessagingService.java
private void startFerriesBulletinActivity(int id, String title, String message, Map data) { // Create an Intent for the activity you want to start Intent resultIntent = new Intent(this, FerriesRouteAlertsBulletinDetailsActivity.class); // Create the TaskStackBuilder and add the intent, which inflates the back stack TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); Bundle b1 = new Bundle(); b1.putInt("routeId", Integer.valueOf(data.get("route_id").toString())); b1.putInt("alertId", Integer.valueOf(data.get("alert_id").toString())); b1.putString("AlertFullTitle", title); b1.putBoolean("from_notification", true); resultIntent.putExtras(b1);//w w w . jav a2 s .c o m resultIntent.setAction("actionstring" + System.currentTimeMillis()); stackBuilder.addNextIntentWithParentStack(resultIntent); Bundle b2 = new Bundle(); b2.putString("title", data.get("route_title").toString()); b2.putInt("routeId", Integer.valueOf(data.get("route_id").toString())); // set extras for the FerriesRouteAlertsBulletinsFragment stackBuilder.editIntentAt(stackBuilder.getIntentCount() - 2).putExtras(b2); // Get the PendingIntent containing the entire back stack PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { NotificationCompat.Builder builder = new NotificationCompat.Builder(this, ALERT_CHANNEL_ID) .setSmallIcon(R.drawable.ic_list_wsdot).setContentTitle(title).setContentText(message) .setChannelId(ALERT_CHANNEL_ID).setStyle(new NotificationCompat.BigTextStyle().bigText(message)) .setContentIntent(resultPendingIntent) .setColor(ContextCompat.getColor(this, R.color.primary_default)).setAutoCancel(true) .setGroup(String.valueOf(System.currentTimeMillis())).setDefaults(Notification.DEFAULT_LIGHTS); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notificationManager.notify(id, builder.build()); } else { NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_list_wsdot).setContentTitle(title).setContentText(message) .setAutoCancel(true).setStyle(new NotificationCompat.BigTextStyle().bigText(message)) .setContentIntent(resultPendingIntent).setWhen(0).setDefaults(Notification.DEFAULT_LIGHTS); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notificationManager.notify(id, builder.build()); } }
From source file:com.battlelancer.seriesguide.billing.BillingActivity.java
/** * Displays a notification that the subscription has expired. Its action opens {@link * BillingActivity}.//from w w w. j a v a2 s .c om */ public static void onExpiredNotification(Context context) { NotificationCompat.Builder nb = new NotificationCompat.Builder(context); // set required attributes nb.setSmallIcon(R.drawable.ic_notification); nb.setContentTitle(context.getString(R.string.subscription_expired)); nb.setContentText(context.getString(R.string.subscription_expired_details)); // set additional attributes nb.setDefaults(Notification.DEFAULT_LIGHTS); nb.setAutoCancel(true); nb.setTicker(context.getString(R.string.subscription_expired_details)); nb.setPriority(NotificationCompat.PRIORITY_DEFAULT); // build task stack Intent notificationIntent = new Intent(context, BillingActivity.class); PendingIntent contentIntent = TaskStackBuilder.create(context) .addNextIntent(new Intent(context, ShowsActivity.class)) .addNextIntent(new Intent(context, SeriesGuidePreferences.class)).addNextIntent(notificationIntent) .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); nb.setContentIntent(contentIntent); // build the notification Notification notification = nb.build(); // show the notification final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(R.string.subscription_expired, notification); }
From source file:com.ubergeek42.WeechatAndroid.service.Notificator.java
private static void makeNoise(Builder builder, Resources res, List<HotMessage> messages) { if (P.notificationTicker) builder.setTicker(messages.size() == 0 ? res.getQuantityString(R.plurals.hot_messages_missing, 1) : messages.get(messages.size() - 1).forTicker()); builder.setPriority(Notification.PRIORITY_HIGH); if (!TextUtils.isEmpty(P.notificationSound)) builder.setSound(Uri.parse(P.notificationSound)); int flags = 0; if (P.notificationLight) flags |= Notification.DEFAULT_LIGHTS; if (P.notificationVibrate) flags |= Notification.DEFAULT_VIBRATE; builder.setDefaults(flags);//ww w . ja va2 s . c o m }
From source file:com.meiste.greg.ptw.gcm.GcmIntentService.java
private void showResultsNotification(final Context context, final String race) { // Only show notification if user wants results notifications final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (prefs.getBoolean(EditPreferences.KEY_NOTIFY_RESULTS, true) && mContainer.getBoolean(GtmHelper.KEY_GAME_ENABLED)) { final Intent notificationIntent = new Intent(context, MainActivity.class); notificationIntent.putExtra(PTW.INTENT_EXTRA_TAB, 2); final PendingIntent pi = PendingIntent.getActivity(context, PI_REQ_CODE, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); int defaults = 0; if (prefs.getBoolean(EditPreferences.KEY_NOTIFY_VIBRATE, true)) defaults |= Notification.DEFAULT_VIBRATE; if (prefs.getBoolean(EditPreferences.KEY_NOTIFY_LED, true)) defaults |= Notification.DEFAULT_LIGHTS; final NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_stat_steering_wheel) .setTicker(context.getString(R.string.remind_results_notify, race)) .setContentTitle(context.getString(R.string.app_name)) .setContentText(context.getString(R.string.remind_results_notify, race)).setContentIntent(pi) .setAutoCancel(true).setDefaults(defaults).setSound(Uri .parse(prefs.getString(EditPreferences.KEY_NOTIFY_RINGTONE, PTW.DEFAULT_NOTIFY_SND))); getNM(context).notify(R.string.remind_results_notify, builder.build()); }/*from w w w . ja v a2 s. c om*/ }
From source file:net.geniecode.ttr.ScheduleReceiver.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") private void setNotification(Context context) { ScrollingText = context.getString(R.string.schedule_postponed_scroll); NotificationText = context.getString(R.string.schedule_postponed_notify); // Trigger a notification that, when clicked, will activate airplane mode mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, ActivateFlightMode.class), PendingIntent.FLAG_CANCEL_CURRENT); Notification notification;//from w w w . ja v a 2 s. com if (android.os.Build.VERSION.SDK_INT >= 11) { Notification.Builder builder = new Notification.Builder(context); builder.setContentIntent(contentIntent).setSmallIcon(R.drawable.ic_launcher).setTicker(ScrollingText) .setWhen(System.currentTimeMillis()).setAutoCancel(true).setOnlyAlertOnce(true) .setDefaults(Notification.DEFAULT_LIGHTS).setContentTitle(context.getText(R.string.app_name)) .setContentText(NotificationText); if (android.os.Build.VERSION.SDK_INT >= 16) { notification = builder.build(); } else { notification = builder.getNotification(); } } else { notification = new Notification(R.drawable.ic_launcher, ScrollingText, System.currentTimeMillis()); notification.setLatestEventInfo(context, context.getText(R.string.app_name), NotificationText, contentIntent); notification.flags |= Notification.FLAG_ONLY_ALERT_ONCE | Notification.FLAG_AUTO_CANCEL; notification.defaults |= Notification.DEFAULT_LIGHTS; } mNotificationManager.notify(NOTIFICATION_ID, notification); }
From source file:com.onesignal.GenerateNotification.java
private static NotificationCompat.Builder getBaseNotificationCompatBuilder(JSONObject gcmBundle, boolean notify) { int notificationIcon = getSmallIconId(gcmBundle); int notificationDefaults = 0; if (OneSignal.getVibrate(currentContext)) notificationDefaults = Notification.DEFAULT_VIBRATE; String message = null;//from w ww .j av a2 s. c o m try { message = gcmBundle.getString("alert"); } catch (Throwable t) { } NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(currentContext).setAutoCancel(true) .setSmallIcon(notificationIcon) // Small Icon required or notification doesn't display .setContentTitle(getTitle(gcmBundle)) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)).setContentText(message); if (notify) notifBuilder.setTicker(message); // Android 5.0 accent color to use, only works when AndroidManifest.xml is // targetSdkVersion >= 21 if (gcmBundle.has("bgac")) { try { notifBuilder.setColor(new BigInteger(gcmBundle.getString("bgac"), 16).intValue()); } catch (Throwable t) { } // Can throw if an old android support lib is used or parse error. } BigInteger ledColor = null; if (notify && gcmBundle.has("ledc")) { try { ledColor = new BigInteger(gcmBundle.getString("ledc"), 16); notifBuilder.setLights(ledColor.intValue(), 2000, 5000); } catch (Throwable t) { notificationDefaults |= Notification.DEFAULT_LIGHTS; } // Can throw if an old android support lib is used or parse error. } else notificationDefaults |= Notification.DEFAULT_LIGHTS; try { int visibility = Notification.VISIBILITY_PUBLIC; if (gcmBundle.has("vis")) visibility = Integer.parseInt(gcmBundle.getString("vis")); notifBuilder.setVisibility(visibility); } catch (Throwable t) { } // Can throw if an old android support lib is used or parse error Bitmap largeIcon = getLargeIcon(gcmBundle); if (largeIcon != null) notifBuilder.setLargeIcon(largeIcon); Bitmap bigPictureIcon = getBitmapIcon(gcmBundle, "bicon"); if (bigPictureIcon != null) notifBuilder.setStyle( new NotificationCompat.BigPictureStyle().bigPicture(bigPictureIcon).setSummaryText(message)); if (notify && OneSignal.getSoundEnabled(currentContext)) { Uri soundUri = getCustomSound(gcmBundle); if (soundUri != null) notifBuilder.setSound(soundUri); else notificationDefaults |= Notification.DEFAULT_SOUND; } if (!notify) notificationDefaults = 0; notifBuilder.setDefaults(notificationDefaults); return notifBuilder; }
From source file:com.tweetlanes.android.service.BackgroundService.java
private Notification buildNotification(String message, int icon, Intent content_intent, Intent delete_intent) { final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setTicker(message);/* w w w. j a v a 2s . com*/ //builder.setContentTitle(getString(R.string.new_notifications)); builder.setContentTitle("New notifications"); builder.setContentText(message); builder.setAutoCancel(true); builder.setWhen(System.currentTimeMillis()); builder.setSmallIcon(icon); builder.setDeleteIntent( PendingIntent.getBroadcast(this, 0, delete_intent, PendingIntent.FLAG_UPDATE_CURRENT)); builder.setContentIntent( PendingIntent.getActivity(this, 0, content_intent, PendingIntent.FLAG_UPDATE_CURRENT)); int defaults = 0; //if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATIONS_HAVE_SOUND, false)) { defaults |= Notification.DEFAULT_SOUND; //} //if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATIONS_HAVE_VIBRATION, false)) { defaults |= Notification.DEFAULT_VIBRATE; //} //if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATIONS_HAVE_LIGHTS, false)) { defaults |= Notification.DEFAULT_LIGHTS; //} builder.setDefaults(defaults); return builder.getNotification(); }