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:com.asb.spandan2014.GcmIntentService.java
private void sendNotification(String msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Intent resultIntent = new Intent(this, AlertsActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // Adds the back stack stackBuilder.addParentStack(AlertsActivity.class); // Adds the Intent to the top of the stack stackBuilder.addNextIntent(resultIntent); // Gets a PendingIntent containing the entire back stack PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.alerts) .setContentTitle(getString(R.string.spandan_update)) .setDefaults(Notification.DEFAULT_VIBRATE | Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_AUTO_CANCEL | Notification.DEFAULT_LIGHTS) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg); mBuilder.setContentIntent(resultPendingIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:name.gudong.translate.listener.view.TipViewController.java
public void show(Result result, boolean isShowFavoriteButton, boolean isShowDoneMark, TipView.ITipViewListener mListener) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext); boolean isSettingUseSystemNotification = sharedPreferences .getBoolean("preference_show_float_view_use_system", false); if (Utils.isSDKHigh5() && isSettingUseSystemNotification) { StringBuilder sb = new StringBuilder(); for (String string : result.getExplains()) { sb.append(string).append("\n"); }//from w w w.j a v a 2s . co m NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext) .setSmallIcon(R.drawable.icon_notification).setContentTitle(result.getQuery()) .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND) .setVibrate(new long[] { 0l }).setPriority(Notification.PRIORITY_HIGH) .setContentText(sb.toString()); /* Add Big View Specific Configuration */ NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); // Moves events into the big view for (String string : result.getExplains()) { inboxStyle.addLine(string); } mBuilder.setStyle(inboxStyle); Intent resultIntent = new Intent(mContext, MainActivity.class); resultIntent.putExtra("data", result); PendingIntent resultPendingIntent = PendingIntent.getActivity(mContext, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.addAction(R.drawable.ic_favorite_border_grey_24dp, "?", resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); Notification note = mBuilder.build(); mNotificationManager.notify(result.getQuery().hashCode(), note); } else { TipView tipView = new TipView(mContext); mMapTipView.put(result, tipView); tipView.setListener(mListener); mWindowManager.addView(tipView, getPopViewParams()); tipView.startWithAnim(); tipView.setContent(result, isShowFavoriteButton, isShowDoneMark); closeTipViewCountdown(tipView, mListener); } }
From source file:org.andicar.service.UpdateCheckService.java
@Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); if (getSharedPreferences(StaticValues.GLOBAL_PREFERENCE_NAME, Context.MODE_MULTI_PROCESS) .getBoolean("SendCrashReport", true)) Thread.setDefaultUncaughtExceptionHandler( new AndiCarExceptionHandler(Thread.getDefaultUncaughtExceptionHandler(), this)); try {/*from w w w .j av a 2 s . c o m*/ Bundle extras = intent.getExtras(); if (extras == null || extras.getBoolean("setJustNextRun") || !extras.getBoolean("AutoUpdateCheck")) { setNextRun(); stopSelf(); } URL updateURL = new URL(StaticValues.VERSION_FILE_URL); URLConnection conn = updateURL.openConnection(); if (conn == null) return; InputStream is = conn.getInputStream(); if (is == null) return; BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); } /* Convert the Bytes read to a String. */ String s = new String(baf.toByteArray()); /* Get current Version Number */ int curVersion = getPackageManager().getPackageInfo("org.andicar.activity", 0).versionCode; int newVersion = Integer.valueOf(s); /* Is a higher version than the current already out? */ if (newVersion > curVersion) { //get the whats new message updateURL = new URL(StaticValues.WHATS_NEW_FILE_URL); conn = updateURL.openConnection(); if (conn == null) return; is = conn.getInputStream(); if (is == null) return; bis = new BufferedInputStream(is); baf = new ByteArrayBuffer(50); current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); } /* Convert the Bytes read to a String. */ s = new String(baf.toByteArray()); mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notification = null; Intent i = new Intent(this, WhatsNewDialog.class); i.putExtra("UpdateMsg", s); PendingIntent contentIntent = PendingIntent.getActivity(UpdateCheckService.this, 0, i, 0); CharSequence title = getText(R.string.Notif_UpdateTitle); String message = getString(R.string.Notif_UpdateMsg); notification = new Notification(R.drawable.icon_sys_info, message, System.currentTimeMillis()); notification.flags |= Notification.DEFAULT_LIGHTS; notification.flags |= Notification.DEFAULT_SOUND; notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.setLatestEventInfo(UpdateCheckService.this, title, message, contentIntent); mNM.notify(StaticValues.NOTIF_UPDATECHECK_ID, notification); setNextRun(); } stopSelf(); } catch (Exception e) { Log.i("UpdateService", "Service failed."); e.printStackTrace(); } }
From source file:com.moxtra.moxiechat.GcmIntentService.java
private void sendMoxtraNotification(String msg, Uri uri, Intent intent) { Log.d(TAG, "Got notification: msg = " + msg + ", uri = " + uri); mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = MXNotificationManager.getMXNotificationIntent(this, intent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_mc_notification) .setContentTitle(getString(getApplicationInfo().labelRes)) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg) .setAutoCancel(true).setDefaults( Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE); if (uri != null) { mBuilder.setSound(uri);/* w ww . jav a 2 s. c o m*/ } mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.meiste.greg.ptw.QuestionAlarm.java
@Override protected void onHandleIntent(final Intent intent) { alarm_set = false;/* ww w .jav a2s . c o m*/ final Race race = Race.getInstance(this, intent.getIntExtra(RACE_ID, 0)); Util.log("Received question alarm for race " + race.getId()); synchronized (mSync) { if (mContainer == null) { try { mSync.wait(); } catch (final InterruptedException e) { } } } // Only show notification if user wants question reminders final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (prefs.getBoolean(EditPreferences.KEY_NOTIFY_QUESTIONS, true) && mContainer.getBoolean(GtmHelper.KEY_GAME_ENABLED)) { final Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.putExtra(PTW.INTENT_EXTRA_TAB, 1); final PendingIntent pi = PendingIntent.getActivity(this, 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(this) .setSmallIcon(R.drawable.ic_stat_steering_wheel) .setTicker(getString(R.string.remind_questions_ticker, race.getName())) .setContentTitle(getString(R.string.app_name)).setContentText(race.getName()) .setContentIntent(pi).setAutoCancel(true).setDefaults(defaults).setSound(Uri .parse(prefs.getString(EditPreferences.KEY_NOTIFY_RINGTONE, PTW.DEFAULT_NOTIFY_SND))); getNM(this).notify(R.string.remind_questions_ticker, builder.build()); } else { Util.log("Ignoring question alarm since option is disabled"); } // Remember that user was reminded of this race Util.getState(this).edit().putInt(LAST_REMIND, race.getId()).apply(); // Reset alarm for the next race set(this); sendBroadcast(new Intent(PTW.INTENT_ACTION_RACE_ALARM)); }
From source file:ro.astazi.andrapp.GcmIntentService.java
private void sendNotification(String title, String msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.putExtra("NotificationTitle", title); notificationIntent.putExtra("NotificationMessage", msg); Log.i(TAG, "NotificationMessage=" + msg); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); //PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setDefaults(/*from w w w .j a v a 2 s .c om*/ Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE) .setTicker(title).setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle(title).setAutoCancel(true) //.setContentText("B" + title) ; mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); /*NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this.getApplicationContext()); notificationBuilder.setContentTitle("GCM Notification"); notificationBuilder.setContentText(msg); notificationBuilder.setTicker("New GCM Notification"); notificationBuilder.setWhen(System.currentTimeMillis()); notificationBuilder.setSmallIcon(R.drawable.ic_stat_gcm); Intent notificationIntent = new Intent(this.getApplicationContext(), MainActivity.class); notificationIntent.putExtra("gabor", msg); PendingIntent contentIntent = PendingIntent.getActivity(this.getApplicationContext(), 1,notificationIntent, 0); notificationBuilder.setContentIntent(contentIntent); notificationBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE); mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = notificationBuilder.build(); notification.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL; mNotificationManager.notify(NOTIFICATION_ID, notification);*/ }
From source file:fr.vassela.acrrd.notifier.TelephoneCallNotifier.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void displayNotification(Context context, String ticker, String contentTitle, String contentText, boolean autoCancel, boolean ongoingEvent, boolean activateEvent) { try {//from w w w .j av a2 s.co 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); Notification.Builder notificationBuilder = new Notification.Builder(context); if (ongoingEvent == false) { notificationBuilder.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) { notificationBuilder.setDefaults(notificationDefaults); } if (activateEvent == true) { notificationBuilder.setSmallIcon(R.drawable.presence_audio_online); } else { notificationBuilder.setSmallIcon(R.drawable.presence_audio_busy); } if (ongoingEvent == false) { notificationBuilder.setTicker(ticker); } notificationBuilder.setContentTitle(contentTitle); notificationBuilder.setContentText(contentText); notificationBuilder.setContentIntent(pendingIntent); notificationBuilder.setAutoCancel(autoCancel); notificationBuilder.setOngoing(ongoingEvent); Notification notification = notificationBuilder.build(); if (ongoingEvent == true) { notificationManager.notify(getOngoingNotificationId(), notification); } else { notificationManager.notify(getNotificationId(), notification); } } } catch (Exception e) { Log.w("TelephoneCallNotifier", "displayNotification : " + 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.bevyios.gcm.BevyGcmListenerService.java
private void sendNotification(Bundle bundle) { Resources resources = getApplication().getResources(); String packageName = getApplication().getPackageName(); Class intentClass = getMainActivityClass(); if (intentClass == null) { return;//from ww w.j av a 2s .c om } if (applicationIsRunning()) { Intent i = new Intent("BevyGCMReceiveNotification"); i.putExtra("bundle", bundle); sendBroadcast(i); return; } int resourceId = resources.getIdentifier(bundle.getString("largeIcon"), "mipmap", packageName); Intent intent = new Intent(this, intentClass); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); //Bitmap largeIcon = BitmapFactory.decodeResource(resources, resourceId); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) //.setLargeIcon(largeIcon) .setSmallIcon(R.drawable.ic_launcher).setContentTitle("title").setContentText("content") .setAutoCancel(false).setSound(defaultSoundUri) //.setTicker(bundle.getString("ticker")) .setCategory(NotificationCompat.CATEGORY_CALL).setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .setPriority(NotificationCompat.PRIORITY_HIGH).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Notification notif = notificationBuilder.build(); notif.defaults |= Notification.DEFAULT_VIBRATE; notif.defaults |= Notification.DEFAULT_SOUND; notif.defaults |= Notification.DEFAULT_LIGHTS; notificationManager.notify(0, notif); }
From source file:com.lugia.timetable.ReminderService.java
@Override protected void onHandleIntent(Intent intent) { String action = intent.getAction(); Log.d("ReminderService", "Handle intent : " + action); Bundle extra = intent.getExtras();//from w ww. j ava2 s . c o m String subjectCode = extra.getString(EXTRA_SUBJECT_CODE); String header = extra.getString(EXTRA_HEADER); String content = extra.getString(EXTRA_CONTENT); String boardcastIntent = null; Intent notificationIntent = new Intent(); Uri soundUri = null; int notificationId; boolean vibrate; if (action.equals(ACTION_SCHEDULE_REMINDER)) { notificationId = SCHEDULE_NOTIFICATION_ID; vibrate = SettingActivity.getBoolean(ReminderService.this, SettingActivity.KEY_SCHEDULE_NOTIFY_VIBRATE, false); String soundUriStr = SettingActivity.getString(ReminderService.this, SettingActivity.KEY_SCHEDULE_NOTIFY_SOUND, ""); notificationIntent.setClass(ReminderService.this, SubjectDetailActivity.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .putExtra(SubjectDetailActivity.EXTRA_SUBJECT_CODE, subjectCode); soundUri = !TextUtils.isEmpty(soundUriStr) ? Uri.parse(soundUriStr) : null; boardcastIntent = ReminderReceiver.ACTION_UPDATE_SCHEDULE_REMINDER; } else if (action.equals(ACTION_EVENT_REMINDER)) { long eventId = intent.getLongExtra(EXTRA_EVENT_ID, -1); notificationId = EVENT_NOTIFICATION_ID; vibrate = SettingActivity.getBoolean(ReminderService.this, SettingActivity.KEY_EVENT_NOTIFY_VIBRATE, false); String soundUriStr = SettingActivity.getString(ReminderService.this, SettingActivity.KEY_EVENT_NOTIFY_SOUND, ""); notificationIntent.setClass(ReminderService.this, SubjectDetailActivity.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setAction(SubjectDetailActivity.ACTION_VIEW_EVENT) .putExtra(SubjectDetailActivity.EXTRA_EVENT_ID, eventId) .putExtra(SubjectDetailActivity.EXTRA_SUBJECT_CODE, subjectCode); soundUri = !TextUtils.isEmpty(soundUriStr) ? Uri.parse(soundUriStr) : null; boardcastIntent = ReminderReceiver.ACTION_UPDATE_EVENT_REMINDER; } else { Log.e(TAG, "Unknow action!"); return; } PendingIntent pendingIntent = PendingIntent.getActivity(ReminderService.this, 0, notificationIntent, 0); Notification notification = new NotificationCompat.Builder(ReminderService.this) .setSmallIcon(R.drawable.ic_notification_reminder).setTicker(header).setContentTitle(header) .setContentText(content).setContentIntent(pendingIntent).setAutoCancel(true) .setWhen(System.currentTimeMillis()).build(); // always show the notification light notification.defaults |= Notification.DEFAULT_LIGHTS; notification.flags |= Notification.FLAG_SHOW_LIGHTS; // only vibrate when user enable it if (vibrate) notification.defaults |= Notification.DEFAULT_VIBRATE; // set the notification sound notification.sound = soundUri; NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); manager.notify(notificationId, notification); // update the reminder, so it will notify user again on next schedule Intent broadcastIntent = new Intent(ReminderService.this, ReminderReceiver.class); broadcastIntent.setAction(boardcastIntent); sendBroadcast(broadcastIntent); }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.receiver.NotificationHelper.java
/** * Displays notifications that have a time occurring in the past (and no * location). If no notifications like that exist, will make sure to cancel * any notifications showing./*from w ww . j a v a2 s . co m*/ */ private static void notifyPast(Context context, boolean alertOnce) { // Get list of past notifications final Calendar now = Calendar.getInstance(); final List<cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification> notifications = cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification .getNotificationsWithTime(context, now.getTimeInMillis(), true); // Remove duplicates makeUnique(context, notifications); final NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Log.d(TAG, "Number of notifications: " + notifications.size()); // If empty, cancel if (notifications.isEmpty()) { // cancelAll permanent notifications here if/when that is // implemented. Don't touch others. // Dont do this, it clears location // notificationManager.cancelAll(); } else { // else, notify // Fetch sound and vibrate settings final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); // Always use default lights int lightAndVibrate = Notification.DEFAULT_LIGHTS; // If vibrate on, use default vibration pattern also if (prefs.getBoolean(context.getString(R.string.const_preference_vibrate_key), false)) lightAndVibrate |= Notification.DEFAULT_VIBRATE; // Need to get a new one because the action buttons will duplicate // otherwise NotificationCompat.Builder builder; // if (false) // // // prefs.getBoolean(context.getString(R.string.key_pref_group_on_lists), // // false)) // { // // Group together notes contained in the same list. // // Always use listid // for (long listId : getRelatedLists(notifications)) { // builder = getNotificationBuilder(context, // Integer.parseInt(prefs.getString( // context.getString(R.string.key_pref_prio), // "0")), lightAndVibrate, // Uri.parse(prefs.getString(context // .getString(R.string.key_pref_ringtone), // "DEFAULT_NOTIFICATION_URI")), alertOnce); // // List<com.nononsenseapps.notepad.data.model.sql.Notification> subList = // getSubList( // listId, notifications); // if (subList.size() == 1) { // // Notify as single // notifyBigText(context, notificationManager, builder, // listId, subList.get(0)); // } // else { // notifyInboxStyle(context, notificationManager, builder, // listId, subList); // } // } // } // else { // Notify for each individually for (cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification note : notifications) { builder = getNotificationBuilder(context, lightAndVibrate, Uri.parse(prefs.getString(context.getString(R.string.const_preference_ringtone_key), "DEFAULT_NOTIFICATION_URI")), alertOnce); notifyBigText(context, notificationManager, builder, note); } // } } }