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:org.linphone.compatibility.ApiFivePlus.java
public static Notification createSimpleNotification(Context context, String title, String text, PendingIntent intent) {//from w w w . j ava2s .c o m NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.logo_linphone_57x57).setContentTitle(title).setContentText(text) .setContentIntent(intent); Notification notif = notifBuilder.build(); notif.defaults |= Notification.DEFAULT_VIBRATE; notif.defaults |= Notification.DEFAULT_SOUND; notif.defaults |= Notification.DEFAULT_LIGHTS; return notif; }
From source file:com.mindprotectionkit.freephone.RedPhoneService.java
public void maybeStartQualityMetricsActivity() { if (currentCallManager.getSessionDescriptor() == null || !currentCallManager.callConnected() || (!ApplicationPreferencesActivity.getDisplayDialogPreference(this) && ApplicationPreferencesActivity.wasUserNotifedOfCallQaulitySettings(this))) { return;/* w ww .j a va2s . co m*/ } SessionDescriptor sessionDescriptor = currentCallManager.getSessionDescriptor(); Intent callQualityDialogIntent = new Intent(this, CallQualityDialog.class); callQualityDialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); callQualityDialogIntent.putExtra("callId", sessionDescriptor.sessionId); startActivity(callQualityDialogIntent); Notification notification = new NotificationCompat.Builder(this).setAutoCancel(true) .setContentTitle(getResources().getText(R.string.CallQualityDialog__redphone)) .setContentText(getResources().getText(R.string.CallQualityDialog__provide_call_quality_feedback)) .setContentIntent(PendingIntent.getActivity(this, 0, callQualityDialogIntent, PendingIntent.FLAG_UPDATE_CURRENT)) .setSmallIcon(R.drawable.registration_notification).setDefaults(Notification.DEFAULT_LIGHTS) .setTicker(getResources().getText(R.string.CallQualityDialog__provide_call_quality_feedback)) .build(); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(CallQualityDialog.CALL_QUALITY_NOTIFICATION_ID, notification); }
From source file:com.xabber.android.data.notification.NotificationManager.java
private void notify(int id, Notification notification) { LogManager.i(this, "Notification: " + id + ", ticker: " + notification.tickerText + ", sound: " + notification.sound + ", vibro: " + (notification.defaults & Notification.DEFAULT_VIBRATE) + ", light: " + (notification.defaults & Notification.DEFAULT_LIGHTS)); try {/*from w w w.j a va 2s . c om*/ notificationManager.notify(id, notification); } catch (SecurityException e) { LogManager.exception(this, e); } }
From source file:im.neon.util.NotificationUtils.java
/** * Build a message notification./*from w ww . j av a2 s .c o m*/ * @param context the context * @param from the sender * @param matrixId the user account id; * @param displayMatrixId true to display the matrix id * @param largeIcon the notification icon * @param unseenNotifiedRoomsCount the number of notified rooms * @param body the message body * @param roomId the room id * @param roomName the room name * @param shouldPlaySound true when the notification as sound. * @param isInvitationEvent true if it is an invitation notification * @return the notification */ public static Notification buildMessageNotification(Context context, String from, String matrixId, boolean displayMatrixId, Bitmap largeIcon, int unseenNotifiedRoomsCount, String body, String roomId, String roomName, boolean shouldPlaySound, boolean isInvitationEvent) { NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setWhen(System.currentTimeMillis()); if (!TextUtils.isEmpty(from)) { // don't display the room name for 1:1 room notifications. if (!TextUtils.isEmpty(roomName) && !roomName.equals(from)) { builder.setContentTitle(from + " (" + roomName + ")"); } else { builder.setContentTitle(from); } } else { builder.setContentTitle(roomName); } builder.setContentText(body); builder.setAutoCancel(true); builder.setSmallIcon(R.drawable.message_notification_transparent); if (null != largeIcon) { largeIcon = createSquareBitmap(largeIcon); // add a bubble in the top right if (0 != unseenNotifiedRoomsCount) { try { android.graphics.Bitmap.Config bitmapConfig = largeIcon.getConfig(); // set default bitmap config if none if (bitmapConfig == null) { bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888; } // setLargeIcon must used a 64 * 64 pixels bitmap // rescale to have the same text UI. float densityScale = context.getResources().getDisplayMetrics().density; int side = (int) (64 * densityScale); Bitmap bitmapCopy = Bitmap.createBitmap(side, side, bitmapConfig); Canvas canvas = new Canvas(bitmapCopy); // resize the bitmap to fill in size int bitmapWidth = largeIcon.getWidth(); int bitmapHeight = largeIcon.getHeight(); float scale = Math.min((float) canvas.getWidth() / (float) bitmapWidth, (float) canvas.getHeight() / (float) bitmapHeight); int scaledWidth = (int) (bitmapWidth * scale); int scaledHeight = (int) (bitmapHeight * scale); Bitmap rescaledBitmap = Bitmap.createScaledBitmap(largeIcon, scaledWidth, scaledHeight, true); canvas.drawBitmap(rescaledBitmap, (side - scaledWidth) / 2, (side - scaledHeight) / 2, null); String text = "" + unseenNotifiedRoomsCount; // prepare the text drawing Paint textPaint = new Paint(); textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); textPaint.setColor(Color.WHITE); textPaint.setTextSize(10 * densityScale); // get its size Rect textBounds = new Rect(); if (-1 == mUnreadBubbleWidth) { textPaint.getTextBounds("99", 0, 2, textBounds); mUnreadBubbleWidth = textBounds.width(); } textPaint.getTextBounds(text, 0, text.length(), textBounds); // draw a red circle int radius = mUnreadBubbleWidth; Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.RED); canvas.drawCircle(canvas.getWidth() - radius, radius, radius, paint); // draw the text canvas.drawText(text, canvas.getWidth() - textBounds.width() - (radius - (textBounds.width() / 2)), -textBounds.top + (radius - (-textBounds.top / 2)), textPaint); // get the new bitmap largeIcon = bitmapCopy; } catch (Exception e) { Log.e(LOG_TAG, "## buildMessageNotification(): Exception Msg=" + e.getMessage()); } } builder.setLargeIcon(largeIcon); } String name = ": "; if (!TextUtils.isEmpty(roomName)) { name = " (" + roomName + "): "; } if (displayMatrixId) { from = "[" + matrixId + "]\n" + from; } builder.setTicker(from + name + body); TaskStackBuilder stackBuilder; Intent intent; intent = new Intent(context, VectorRoomActivity.class); intent.putExtra(VectorRoomActivity.EXTRA_ROOM_ID, roomId); if (null != matrixId) { intent.putExtra(VectorRoomActivity.EXTRA_MATRIX_ID, matrixId); } stackBuilder = TaskStackBuilder.create(context).addParentStack(VectorRoomActivity.class) .addNextIntent(intent); // android 4.3 issue // use a generator for the private requestCode. // When using 0, the intent is not created/launched when the user taps on the notification. // PendingIntent pendingIntent = stackBuilder.getPendingIntent((new Random()).nextInt(1000), PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pendingIntent); // display the message with more than 1 lines when the device supports it NotificationCompat.BigTextStyle textStyle = new NotificationCompat.BigTextStyle(); textStyle.bigText(from + ":" + body); builder.setStyle(textStyle); // do not offer to quick respond if the user did not dismiss the previous one if (!LockScreenActivity.isDisplayingALockScreenActivity()) { if (!isInvitationEvent) { // offer to type a quick answer (i.e. without launching the application) Intent quickReplyIntent = new Intent(context, LockScreenActivity.class); quickReplyIntent.putExtra(LockScreenActivity.EXTRA_ROOM_ID, roomId); quickReplyIntent.putExtra(LockScreenActivity.EXTRA_SENDER_NAME, from); quickReplyIntent.putExtra(LockScreenActivity.EXTRA_MESSAGE_BODY, body); if (null != matrixId) { quickReplyIntent.putExtra(LockScreenActivity.EXTRA_MATRIX_ID, matrixId); } // the action must be unique else the parameters are ignored quickReplyIntent.setAction(QUICK_LAUNCH_ACTION + ((int) (System.currentTimeMillis()))); PendingIntent pIntent = PendingIntent.getActivity(context, 0, quickReplyIntent, 0); builder.addAction(R.drawable.vector_notification_quick_reply, context.getString(R.string.action_quick_reply), pIntent); } else { { // offer to type a quick reject button Intent leaveIntent = new Intent(context, JoinScreenActivity.class); leaveIntent.putExtra(JoinScreenActivity.EXTRA_ROOM_ID, roomId); leaveIntent.putExtra(JoinScreenActivity.EXTRA_MATRIX_ID, matrixId); leaveIntent.putExtra(JoinScreenActivity.EXTRA_REJECT, true); // the action must be unique else the parameters are ignored leaveIntent.setAction(QUICK_LAUNCH_ACTION + ((int) (System.currentTimeMillis()))); PendingIntent pIntent = PendingIntent.getActivity(context, 0, leaveIntent, 0); builder.addAction(R.drawable.vector_notification_reject_invitation, context.getString(R.string.reject), pIntent); } { // offer to type a quick accept button Intent acceptIntent = new Intent(context, JoinScreenActivity.class); acceptIntent.putExtra(JoinScreenActivity.EXTRA_ROOM_ID, roomId); acceptIntent.putExtra(JoinScreenActivity.EXTRA_MATRIX_ID, matrixId); acceptIntent.putExtra(JoinScreenActivity.EXTRA_JOIN, true); // the action must be unique else the parameters are ignored acceptIntent.setAction(QUICK_LAUNCH_ACTION + ((int) (System.currentTimeMillis()))); PendingIntent pIntent = PendingIntent.getActivity(context, 0, acceptIntent, 0); builder.addAction(R.drawable.vector_notification_accept_invitation, context.getString(R.string.join), pIntent); } } // Build the pending intent for when the notification is clicked Intent roomIntentTap; if (isInvitationEvent) { // for invitation the room preview must be displayed roomIntentTap = CommonActivityUtils.buildIntentPreviewRoom(matrixId, roomId, context, VectorFakeRoomPreviewActivity.class); } else { roomIntentTap = new Intent(context, VectorRoomActivity.class); roomIntentTap.putExtra(VectorRoomActivity.EXTRA_ROOM_ID, roomId); } // the action must be unique else the parameters are ignored roomIntentTap.setAction(TAP_TO_VIEW_ACTION + ((int) (System.currentTimeMillis()))); // Recreate the back stack TaskStackBuilder stackBuilderTap = TaskStackBuilder.create(context) .addParentStack(VectorRoomActivity.class).addNextIntent(roomIntentTap); builder.addAction(R.drawable.vector_notification_open, context.getString(R.string.action_open), stackBuilderTap.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)); } //extendForCar(context, builder, roomId, roomName, from, body); Notification n = builder.build(); n.flags |= Notification.FLAG_SHOW_LIGHTS; n.defaults |= Notification.DEFAULT_LIGHTS; if (shouldPlaySound) { n.defaults |= Notification.DEFAULT_SOUND; } if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { // some devices crash if this field is not set // even if it is deprecated // setLatestEventInfo() is deprecated on Android M, so we try to use // reflection at runtime, to avoid compiler error: "Cannot resolve method.." try { Method deprecatedMethod = n.getClass().getMethod("setLatestEventInfo", Context.class, CharSequence.class, CharSequence.class, PendingIntent.class); deprecatedMethod.invoke(n, context, from, body, pendingIntent); } catch (Exception ex) { Log.e(LOG_TAG, "## buildMessageNotification(): Exception - setLatestEventInfo() Msg=" + ex.getMessage()); } } return n; }
From source file:com.lambdasoup.quickfit.alarm.AlarmService.java
@WorkerThread private void refreshNotificationDisplay() { try (Cursor toNotify = getContentResolver().query(QuickFitContentProvider.getUriWorkoutsList(), new String[] { WorkoutEntry.SCHEDULE_ID, WorkoutEntry.WORKOUT_ID, WorkoutEntry.ACTIVITY_TYPE, WorkoutEntry.LABEL, WorkoutEntry.DURATION_MINUTES }, ScheduleEntry.TABLE_NAME + "." + ScheduleEntry.COL_SHOW_NOTIFICATION + "=?", new String[] { Integer.toString(ScheduleEntry.SHOW_NOTIFICATION_YES) }, null)) { int count = toNotify == null ? 0 : toNotify.getCount(); if (count == 0) { Timber.d("refreshNotificationDisplay: no events"); NotificationManager notificationManager = (NotificationManager) getSystemService( NOTIFICATION_SERVICE); notificationManager.cancel(Constants.NOTIFICATION_ALARM); return; }//from www .j a v a 2 s . com long[] scheduleIds = new long[count]; int i = 0; toNotify.moveToPosition(-1); while (toNotify.moveToNext()) { scheduleIds[i] = toNotify.getLong(toNotify.getColumnIndex(WorkoutEntry.SCHEDULE_ID)); i++; } PendingIntent cancelIntent = PendingIntent.getService(getApplicationContext(), 0, getIntentOnNotificationsCanceled(this, scheduleIds), PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder notification; if (count == 1) { Timber.d("refreshNotificationDisplay: single event"); toNotify.moveToFirst(); notification = notifySingleEvent(toNotify, cancelIntent); } else { Timber.d("refreshNotificationDisplay: multiple events"); toNotify.moveToPosition(-1); notification = notifyMultipleEvents(toNotify, cancelIntent); } notification.setDeleteIntent(cancelIntent); notification.setAutoCancel(true); notification.setPriority(Notification.PRIORITY_HIGH); notification.setSmallIcon(R.drawable.ic_stat_quickfit_icon); notification.setColor(ContextCompat.getColor(this, R.color.colorPrimary)); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); String ringtoneUriStr = preferences.getString(getString(R.string.pref_key_notification_ringtone), null); if (ringtoneUriStr == null) { notification.setSound( RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_NOTIFICATION)); } else if (!ringtoneUriStr.isEmpty()) { notification.setSound(Uri.parse(ringtoneUriStr)); } boolean ledOn = preferences.getBoolean(getString(R.string.pref_key_notification_led), true); boolean vibrationOn = preferences.getBoolean(getString(R.string.pref_key_notification_vibrate), true); notification.setDefaults( (ledOn ? Notification.DEFAULT_LIGHTS : 0) | (vibrationOn ? Notification.DEFAULT_VIBRATE : 0)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { notification.setCategory(Notification.CATEGORY_ALARM); } NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(Constants.NOTIFICATION_ALARM, notification.build()); } }
From source file:com.android.email.EmailNotificationController.java
/** Sets up the notification's sound and vibration based upon account details. */ private void setupSoundAndVibration(NotificationCompat.Builder builder, Account account) { String ringtoneUri = Settings.System.DEFAULT_NOTIFICATION_URI.toString(); boolean vibrate = false; // Use the Inbox notification preferences final Cursor accountCursor = mContext.getContentResolver().query( EmailProvider.uiUri("uiaccount", account.mId), UIProvider.ACCOUNTS_PROJECTION, null, null, null); com.android.mail.providers.Account uiAccount = null; try {/*from w ww . ja v a 2 s. c o m*/ if (accountCursor.moveToFirst()) { uiAccount = com.android.mail.providers.Account.builder().buildFrom(accountCursor); } } finally { accountCursor.close(); } if (uiAccount != null) { final Cursor folderCursor = mContext.getContentResolver().query(uiAccount.settings.defaultInbox, UIProvider.FOLDERS_PROJECTION, null, null, null); if (folderCursor == null) { // This can happen when the notification is for the security policy notification // that happens before the account is setup LogUtils.w(LOG_TAG, "Null folder cursor for mailbox %s", uiAccount.settings.defaultInbox); } else { Folder folder = null; try { if (folderCursor.moveToFirst()) { folder = new Folder(folderCursor); } } finally { folderCursor.close(); } if (folder != null) { final FolderPreferences folderPreferences = new FolderPreferences(mContext, uiAccount.getEmailAddress(), folder, true /* inbox */); ringtoneUri = folderPreferences.getNotificationRingtoneUri(); vibrate = folderPreferences.isNotificationVibrateEnabled(); } else { LogUtils.e(LOG_TAG, "Null folder for mailbox %s", uiAccount.settings.defaultInbox); } } } else { LogUtils.e(LOG_TAG, "Null uiAccount for account id %d", account.mId); } int defaults = Notification.DEFAULT_LIGHTS; if (vibrate) { defaults |= Notification.DEFAULT_VIBRATE; } builder.setSound(TextUtils.isEmpty(ringtoneUri) ? null : Uri.parse(ringtoneUri)).setDefaults(defaults); }
From source file:com.indeema.email.NotificationController.java
/** Sets up the notification's sound and vibration based upon account details. */ private void setupSoundAndVibration(NotificationCompat.Builder builder, Account account) { String ringtoneUri = Settings.System.DEFAULT_NOTIFICATION_URI.toString(); boolean vibrate = false; // Use the Inbox notification preferences final Cursor accountCursor = mContext.getContentResolver().query( EmailProvider.uiUri("uiaccount", account.mId), UIProvider.ACCOUNTS_PROJECTION, null, null, null); com.indeema.mail.providers.Account uiAccount = null; try {/*from w w w .j a v a 2s. c om*/ if (accountCursor.moveToFirst()) { uiAccount = new com.indeema.mail.providers.Account(accountCursor); } } finally { accountCursor.close(); } if (uiAccount != null) { final Cursor folderCursor = mContext.getContentResolver().query(uiAccount.settings.defaultInbox, UIProvider.FOLDERS_PROJECTION, null, null, null); if (folderCursor == null) { // This can happen when the notification is for the security policy notification // that happens before the account is setup LogUtils.w(LOG_TAG, "Null folder cursor for mailbox %s", uiAccount.settings.defaultInbox); } else { Folder folder = null; try { if (folderCursor.moveToFirst()) { folder = new Folder(folderCursor); } } finally { folderCursor.close(); } if (folder != null) { final FolderPreferences folderPreferences = new FolderPreferences(mContext, uiAccount.getEmailAddress(), folder, true /* inbox */); ringtoneUri = folderPreferences.getNotificationRingtoneUri(); vibrate = folderPreferences.isNotificationVibrateEnabled(); } else { LogUtils.e(LOG_TAG, "Null folder for mailbox %s", uiAccount.settings.defaultInbox); } } } else { LogUtils.e(LOG_TAG, "Null uiAccount for account id %d", account.mId); } int defaults = Notification.DEFAULT_LIGHTS; if (vibrate) { defaults |= Notification.DEFAULT_VIBRATE; } builder.setSound(TextUtils.isEmpty(ringtoneUri) ? null : Uri.parse(ringtoneUri)).setDefaults(defaults); }
From source file:com.android.email.NotificationController.java
/** Sets up the notification's sound and vibration based upon account details. */ private void setupSoundAndVibration(NotificationCompat.Builder builder, Account account) { String ringtoneUri = Settings.System.DEFAULT_NOTIFICATION_URI.toString(); boolean vibrate = false; // Use the Inbox notification preferences final Cursor accountCursor = mContext.getContentResolver().query( EmailProvider.uiUri("uiaccount", account.mId), UIProvider.ACCOUNTS_PROJECTION, null, null, null); com.android.mail.providers.Account uiAccount = null; try {//from w ww .jav a 2s . co m if (accountCursor.moveToFirst()) { uiAccount = new com.android.mail.providers.Account(accountCursor); } } finally { accountCursor.close(); } if (uiAccount != null) { final Cursor folderCursor = mContext.getContentResolver().query(uiAccount.settings.defaultInbox, UIProvider.FOLDERS_PROJECTION, null, null, null); if (folderCursor == null) { // This can happen when the notification is for the security policy notification // that happens before the account is setup LogUtils.w(LOG_TAG, "Null folder cursor for mailbox %s", uiAccount.settings.defaultInbox); } else { Folder folder = null; try { if (folderCursor.moveToFirst()) { folder = new Folder(folderCursor); } } finally { folderCursor.close(); } if (folder != null) { final FolderPreferences folderPreferences = new FolderPreferences(mContext, uiAccount.getEmailAddress(), folder, true /* inbox */); ringtoneUri = folderPreferences.getNotificationRingtoneUri(); vibrate = folderPreferences.isNotificationVibrateEnabled(); } else { LogUtils.e(LOG_TAG, "Null folder for mailbox %s", uiAccount.settings.defaultInbox); } } } else { LogUtils.e(LOG_TAG, "Null uiAccount for account id %d", account.mId); } int defaults = Notification.DEFAULT_LIGHTS; if (vibrate) { defaults |= Notification.DEFAULT_VIBRATE; } builder.setSound(TextUtils.isEmpty(ringtoneUri) ? null : Uri.parse(ringtoneUri)).setDefaults(defaults); }
From source file:com.wondertoys.pokevalue.utils.AutoUpdateApk.java
protected void raise_notification() { String ns = Context.NOTIFICATION_SERVICE; NotificationManager nm = (NotificationManager) context.getSystemService(ns); String update_file = preferences.getString(UPDATE_FILE, ""); if (update_file.length() > 0) { setChanged();//from ww w . jav a2s . c om notifyObservers(AUTOUPDATE_HAVE_UPDATE); // raise the notification CharSequence contentTitle = appName + " update available"; CharSequence contentText = "Select to install"; Intent notificationIntent = new Intent(Intent.ACTION_VIEW); notificationIntent.setDataAndType(Uri.parse( "file://" + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/" + update_file), ANDROID_PACKAGE); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setDefaults( Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE); builder.setSmallIcon(appIcon); builder.setTicker(appName + " update"); builder.setContentTitle(contentTitle); builder.setContentText(contentText); builder.setContentIntent(contentIntent); builder.setWhen(System.currentTimeMillis()); builder.setAutoCancel(true); builder.setOngoing(true); nm.notify(NOTIFICATION_ID, builder.build()); } else { //nm.cancel( NOTIFICATION_ID ); // tried this, but it just doesn't do the trick =( nm.cancelAll(); } }
From source file:com.mattprecious.notisync.service.SecondaryService.java
private void handleGtalkMessage(GtalkMessage message) { if (!Preferences.getSecondaryGtalkEnabled(this)) { return;/*w w w . ja v a2 s . c o m*/ } if (Preferences.getSecondaryGtalkUnconnectedOnly(this)) { if (isNetworkAvailable()) { return; } } if (gtalkMessages.containsKey(message.sender)) { List<GtalkMessage> messages = gtalkMessages.remove(message.sender); messages.add(message); gtalkMessages.put(message.sender, messages); } else { List<GtalkMessage> list = Lists.newArrayList(); list.add(message); gtalkMessages.put(message.sender, list); } NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.drawable.package_talk); builder.setSound(getRingtoneUri(Preferences.getSecondaryGtalkRingtone(this))); builder.setAutoCancel(true); int defaults = 0; if (Preferences.getSecondaryGtalkVibrate(this)) { defaults |= Notification.DEFAULT_VIBRATE; } if (Preferences.getSecondaryGtalkLights(this)) { defaults |= Notification.DEFAULT_LIGHTS; } builder.setDefaults(defaults); PendingIntent deleteIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_GTALK_NOTIFICATION_DELETED), 0); builder.setContentIntent(deleteIntent); builder.setDeleteIntent(deleteIntent); List<List<NotificationData>> threadList = Lists.newArrayList(); List<Entry<String, List<GtalkMessage>>> entryList = Lists .reverse(Lists.newArrayList(gtalkMessages.entrySet())); for (Entry<String, List<GtalkMessage>> entry : entryList) { List<NotificationData> data = Lists.newArrayList(); for (GtalkMessage msg : entry.getValue()) { data.add(new NotificationData(msg.sender, msg.message)); } threadList.add(data); } notificationManager.notify(NOTIFICATION_ID_GTALK, buildRichNotification(builder, threadList, null)); openNotificationDatabaseWrite(); notificationsDbAdapter.insertNotification("com.google.android.talk", "talk", "Hangouts", message.sender, message.message, System.currentTimeMillis() + ""); notificationsDbAdapter.close(); }