List of usage examples for android.app Notification FLAG_AUTO_CANCEL
int FLAG_AUTO_CANCEL
To view the source code for android.app Notification FLAG_AUTO_CANCEL.
Click Source Link
From source file:com.unfc.choicecustomercare.gcmservices.MyGcmListenerService.java
private void sendNotificationForChargedNurse(String message) { Intent intent = new Intent(this, MainActivity.class); intent.setAction("chargedNurse"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Intent intentAccept = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingAccept = PendingIntent.getActivity(this, 1, intentAccept, PendingIntent.FLAG_ONE_SHOT); ///* ww w . j av a2 s. c om*/ Intent intentDecline = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingDecline = PendingIntent.getActivity(this, 2, intentDecline, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(getString(R.string.app_name)) .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent).setAutoCancel(true); notificationBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL; notificationBuilder.setAutoCancel(true); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify((int) new Date().getTime(), notificationBuilder.build()); }
From source file:org.mozilla.gecko.updater.UpdateService.java
private void startUpdate(int flags) { setLastAttemptDate();//from w ww .ja v a 2 s .c om NetworkInfo netInfo = mConnectivityManager.getActiveNetworkInfo(); if (netInfo == null || !netInfo.isConnected()) { Log.i(LOGTAG, "not connected to the network"); registerForUpdates(true); sendCheckUpdateResult(CheckUpdateResult.NOT_AVAILABLE); return; } registerForUpdates(false); UpdateInfo info = findUpdate(hasFlag(flags, UpdateServiceHelper.FLAG_REINSTALL)); boolean haveUpdate = (info != null); if (!haveUpdate) { Log.i(LOGTAG, "no update available"); sendCheckUpdateResult(CheckUpdateResult.NOT_AVAILABLE); return; } Log.i(LOGTAG, "update available, buildID = " + info.buildID); AutoDownloadPolicy policy = getAutoDownloadPolicy(); // We only start a download automatically if one of following criteria are met: // // - We have a FORCE_DOWNLOAD flag passed in // - The preference is set to 'always' // - The preference is set to 'wifi' and we are using a non-metered network (i.e. the user // is OK with large data transfers occurring) // boolean shouldStartDownload = hasFlag(flags, UpdateServiceHelper.FLAG_FORCE_DOWNLOAD) || policy == AutoDownloadPolicy.ENABLED || (policy == AutoDownloadPolicy.WIFI && !ConnectivityManagerCompat.isActiveNetworkMetered(mConnectivityManager)); if (!shouldStartDownload) { Log.i(LOGTAG, "not initiating automatic update download due to policy " + policy.toString()); sendCheckUpdateResult(CheckUpdateResult.AVAILABLE); // We aren't autodownloading here, so prompt to start the update Notification notification = new Notification(R.drawable.ic_status_logo, null, System.currentTimeMillis()); Intent notificationIntent = new Intent(UpdateServiceHelper.ACTION_DOWNLOAD_UPDATE); notificationIntent.setClass(this, UpdateService.class); PendingIntent contentIntent = PendingIntent.getService(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.flags = Notification.FLAG_AUTO_CANCEL; notification.setLatestEventInfo(this, getResources().getString(R.string.updater_start_title), getResources().getString(R.string.updater_start_select), contentIntent); mNotificationManager.notify(NOTIFICATION_ID, notification); return; } File pkg = downloadUpdatePackage(info, hasFlag(flags, UpdateServiceHelper.FLAG_OVERWRITE_EXISTING)); if (pkg == null) { sendCheckUpdateResult(CheckUpdateResult.NOT_AVAILABLE); return; } Log.i(LOGTAG, "have update package at " + pkg); saveUpdateInfo(info, pkg); sendCheckUpdateResult(CheckUpdateResult.DOWNLOADED); if (mApplyImmediately) { applyUpdate(pkg); } else { // Prompt to apply the update Notification notification = new Notification(R.drawable.ic_status_logo, null, System.currentTimeMillis()); Intent notificationIntent = new Intent(UpdateServiceHelper.ACTION_APPLY_UPDATE); notificationIntent.setClass(this, UpdateService.class); notificationIntent.putExtra(UpdateServiceHelper.EXTRA_PACKAGE_PATH_NAME, pkg.getAbsolutePath()); PendingIntent contentIntent = PendingIntent.getService(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.flags = Notification.FLAG_AUTO_CANCEL; notification.setLatestEventInfo(this, getResources().getString(R.string.updater_apply_title), getResources().getString(R.string.updater_apply_select), contentIntent); mNotificationManager.notify(NOTIFICATION_ID, notification); } }
From source file:it.mb.whatshare.SendToGCMActivity.java
@SuppressWarnings("deprecation") private void showNotification(int sharedWhat, boolean sharedViaWhatsapp) { String title = getString(R.string.whatshare); Intent onNotificationDiscarded = new Intent(this, SendToGCMActivity.class); PendingIntent notificationIntent = PendingIntent.getActivity(this, 0, onNotificationDiscarded, 0); Notification notification = null; int notificationIcon = sharedViaWhatsapp ? R.drawable.notification_icon : R.drawable.whatshare_logo_notification; int notificationNumber = notificationCounter.incrementAndGet(); String content = getString(R.string.share_success, getString(sharedWhat), outboundDevice.type); // @formatter:off NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setSmallIcon(notificationIcon, 0) .setContentTitle(title).setContentText(content).setTicker(content) .setContentIntent(notificationIntent) .setDeleteIntent(PendingIntent.getActivity(this, 0, onNotificationDiscarded, 0)) .setNumber(notificationNumber); // @formatter:on if (Build.VERSION.SDK_INT > 15) { notification = buildForJellyBean(builder); } else {/* w ww .j ava 2s . c o m*/ notification = builder.getNotification(); } notification.flags |= Notification.FLAG_AUTO_CANCEL; NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // cancel previous notification to clean up garbage in the status bar nm.cancel(notificationNumber - 1); nm.notify(notificationNumber, notification); }
From source file:org.alfresco.mobile.android.platform.AlfrescoNotificationManager.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public int createNotification(int notificationId, Bundle params) { Notification notification;//w w w . ja v a2 s .c o m // Get the builder to create notification. NotificationCompat.Builder builder = new NotificationCompat.Builder(appContext.getApplicationContext()); builder.setContentTitle(params.getString(ARGUMENT_TITLE)); if (params.containsKey(ARGUMENT_DESCRIPTION)) { builder.setContentText(params.getString(ARGUMENT_DESCRIPTION)); } builder.setNumber(0); if (AndroidVersion.isLollipopOrAbove()) { builder.setSmallIcon(R.drawable.ic_notification); builder.setColor(appContext.getResources().getColor(R.color.alfresco_sky)); } else { builder.setSmallIcon(R.drawable.ic_notification); } if (params.containsKey(ARGUMENT_DESCRIPTION)) { builder.setContentText(params.getString(ARGUMENT_DESCRIPTION)); } if (params.containsKey(ARGUMENT_CONTENT_INFO)) { builder.setContentInfo(params.getString(ARGUMENT_CONTENT_INFO)); } if (params.containsKey(ARGUMENT_SMALL_ICON)) { builder.setSmallIcon(params.getInt(ARGUMENT_SMALL_ICON)); } Intent i; PendingIntent pIntent; switch (notificationId) { case CHANNEL_SYNC: i = new Intent(PrivateIntent.ACTION_SYNCHRO_DISPLAY); pIntent = PendingIntent.getActivity(appContext, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); break; default: i = new Intent(PrivateIntent.ACTION_DISPLAY_OPERATIONS); i.putExtra(PrivateIntent.EXTRA_OPERATIONS_TYPE, notificationId); if (SessionUtils.getAccount(appContext) != null) { i.putExtra(PrivateIntent.EXTRA_ACCOUNT_ID, SessionUtils.getAccount(appContext).getId()); } pIntent = PendingIntent.getActivity(appContext, 0, i, 0); break; } builder.setContentIntent(pIntent); if (AndroidVersion.isICSOrAbove()) { if (params.containsKey(ARGUMENT_PROGRESS_MAX) && params.containsKey(ARGUMENT_PROGRESS)) { long max = params.getLong(ARGUMENT_PROGRESS_MAX); long progress = params.getLong(ARGUMENT_PROGRESS); float value = (((float) progress / ((float) max)) * 100); int percentage = Math.round(value); builder.setProgress(100, percentage, false); } if (params.getBoolean(ARGUMENT_INDETERMINATE)) { builder.setProgress(0, 0, true); } } else { RemoteViews remote = new RemoteViews(appContext.getPackageName(), R.layout.app_notification); remote.setImageViewResource(R.id.status_icon, R.drawable.ic_application_logo); remote.setTextViewText(R.id.status_text, params.getString(ARGUMENT_TITLE)); remote.setProgressBar(R.id.status_progress, params.getInt(ARGUMENT_PROGRESS_MAX), 0, false); builder.setContent(remote); } if (AndroidVersion.isJBOrAbove()) { builder.setPriority(0); notification = builder.build(); } else { notification = builder.getNotification(); } notification.flags |= Notification.FLAG_AUTO_CANCEL; ((NotificationManager) appContext.getSystemService(Context.NOTIFICATION_SERVICE)).notify(notificationId, notification); return notificationId; }
From source file:org.zywx.wbpalmstar.platform.push.PushRecieveMsgReceiver.java
private void oldPushNotification(Context context, Intent intent) { PushReportUtility.log("oldPushNotification->isForground = " + EBrowserActivity.isForground); if (EBrowserActivity.isForground) { if (mContext != null) { intent.putExtra("ntype", F_TYPE_PUSH); ((EBrowserActivity) mContext).handleIntent(intent); }// w w w . ja v a 2 s.c o m } else { CharSequence tickerText = intent.getStringExtra("title"); // ???? Resources res = context.getResources(); int icon = res.getIdentifier("icon", "drawable", intent.getPackage()); long when = System.currentTimeMillis(); // ? // ??Nofification String notifyTitle = null; String pushMessage = intent.getStringExtra("message"); String value = intent.getStringExtra("data"); // ??json try { JSONObject bodyJson = new JSONObject(value); notifyTitle = bodyJson.getString("msgName");// ? } catch (Exception e) { PushReportUtility.oe("onReceive", e); } if (TextUtils.isEmpty(notifyTitle)) { notifyTitle = intent.getStringExtra("widgetName");// msgNamewidgetName? } if (TextUtils.isEmpty(notifyTitle)) { notifyTitle = "APPCAN";// widgetNameAPPCAN? } CharSequence contentTitle = notifyTitle; // ? Intent notificationIntent = new Intent(context, EBrowserActivity.class); // ??Activity notificationIntent.putExtra("data", value); notificationIntent.putExtra("message", pushMessage); notificationIntent.putExtra("ntype", F_TYPE_PUSH); String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); Notification notification = new Notification(icon, tickerText, when); notification.flags = Notification.FLAG_AUTO_CANCEL; notification.defaults |= Notification.DEFAULT_SOUND; if (Build.VERSION.SDK_INT >= 16) { try { Field priorityField = Notification.class.getField("priority"); priorityField.setAccessible(true); priorityField.set(notification, 1); } catch (Exception e) { PushReportUtility.oe("onReceive", e); } } PendingIntent contentIntent = PendingIntent.getActivity(context, notificationNB, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, contentTitle, tickerText, contentIntent); // NotificationNotificationManager mNotificationManager.notify(notificationNB, notification); notificationNB++; } }
From source file:org.crossconnect.bible.activity.main.ResourceFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); resourceService = ((MainActivity) getActivity()).getResourceService(); // Prepare the loader. Either re-connect with an existing one, // or start a new one. Bundle bundle = new Bundle(); bundle.putParcelable("BibleText", Utils.loadBibleText(getActivity().getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE))); getLoaderManager().initLoader(0, bundle, this); // Create an empty adapter we will use to display the loaded data. mAdapter = new ResourceListAdapter(getActivity()); setListAdapter(mAdapter);//w ww . j a v a 2s .c om dm = ((DownloadManager) getActivity().getSystemService("download")); BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) { long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0); Query query = new Query(); query.setFilterById(enqueue); Cursor c = dm.query(query); if (c.moveToFirst()) { int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS); if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(columnIndex)) { String uriString = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)); } } String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getActivity() .getSystemService(ns); int icon = R.drawable.icon_book_rss; CharSequence tickerText = "Resource Download Complete"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); CharSequence contentTitle = "Download Complete"; CharSequence contentText = "Click to view downloaded resources"; Intent notificationIntent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //uncomment when better // Intent notificationIntent = new Intent(getActivity(), MusicActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(getActivity(), 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); notification.flags |= Notification.FLAG_AUTO_CANCEL; int HELLO_ID = 1; mNotificationManager.notify(HELLO_ID, notification); } } }; getActivity().registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); }
From source file:com.gdpi.app.UpdateManager.java
/** * Nitify//from w w w .ja v a 2 s .c o m */ @SuppressWarnings({ "unused", "deprecation" }) @TargetApi(16) private void closeNitify() { nitify.flags = Notification.FLAG_AUTO_CANCEL; nitify.contentView = null; Intent intent = new Intent(mContext, MainFragment.class); // ? intent.putExtra("completed", "yes"); // ?,?flags?FLAG_UPDATE_CURRENT PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); nitify = new Notification.Builder(mContext).setAutoCancel(true).setContentTitle("?") .setContentText("").setContentIntent(contentIntent) .setSmallIcon(R.drawable.icon).setWhen(System.currentTimeMillis()).build(); mNotificationManager.notify(notifyId, nitify); }
From source file:dk.microting.softkeyboard.autoupdateapk.AutoUpdateApk.java
private 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) { // raise notification Notification notification = new Notification(appIcon, appName + " update", System.currentTimeMillis()); notification.flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_NO_CLEAR; CharSequence contentTitle = appName + " update available"; CharSequence contentText = "Select to install"; Intent notificationIntent = new Intent(Intent.ACTION_VIEW); notificationIntent.setDataAndType( Uri.parse("file://" + context.getFilesDir().getAbsolutePath() + "/" + update_file), ANDROID_PACKAGE);// w w w. j av a 2 s. c om PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); nm.notify(NOTIFICATION_ID, notification); } else { nm.cancel(NOTIFICATION_ID); } }
From source file:com.adarshahd.indianrailinfo.donate.PNRTracker.java
private void showNotification(String title, String contentText, ArrayList<String> inboxVal, String activityToStart) { NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mContext); notificationBuilder.setSmallIcon(R.drawable.irctc).setContentTitle(title).setContentText(contentText); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); for (String str : inboxVal) { inboxStyle.addLine(str);//w w w. j ava 2 s . c o m } notificationBuilder.setStyle(inboxStyle); notificationBuilder.setOnlyAlertOnce(true); if (!activityToStart.equals("")) { Intent intent = new Intent(mContext, PNRStat.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(Presenter.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(intent); PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); notificationBuilder.setContentIntent(pendingIntent); } NotificationManager notificationManager = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); Notification notify = notificationBuilder.build(); //notify.sound = Uri.parse("content://settings/system/notification_sound"); notify.sound = Uri .parse(mPref.getString("notification_ringtone", "content://settings/system/notification_sound")); notify.ledARGB = 0xFF00FF00; notify.ledOffMS = 10000; notify.ledOnMS = 1500; notify.flags |= Notification.FLAG_AUTO_CANCEL; notify.flags |= Notification.FLAG_SHOW_LIGHTS; if (mPref.getBoolean("notification_vibrate", true)) { //Should find out a way to vibrate long[] pattern = { 0, 200 }; notify.vibrate = pattern; } /*notify.flags = Notification.DEFAULT_ALL; notify.flags |= Notification.FLAG_ONLY_ALERT_ONCE; notify.flags |= Notification.DEFAULT_SOUND; notify.flags |= Notification.DEFAULT_LIGHTS;*/ notificationManager.notify(0, notify); }
From source file:com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.java
private void generateNotification(Context context, String ticker, String title, String msg, int icon, Intent intent, String sound, int notificationId, MFPInternalPushMessage message) { int androidSDKVersion = Build.VERSION.SDK_INT; long when = System.currentTimeMillis(); Notification notification = null; NotificationCompat.Builder builder = new NotificationCompat.Builder(this); if (message.getGcmStyle() != null && androidSDKVersion > 21) { NotificationCompat.Builder mBuilder = null; NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); try {/*from w ww . ja va 2s .c om*/ JSONObject gcmStyleObject = new JSONObject(message.getGcmStyle()); String type = gcmStyleObject.getString(TYPE); if (type != null && type.equalsIgnoreCase(PICTURE_NOTIFICATION)) { Bitmap remote_picture = null; NotificationCompat.BigPictureStyle notificationStyle = new NotificationCompat.BigPictureStyle(); notificationStyle.setBigContentTitle(ticker); notificationStyle.setSummaryText(gcmStyleObject.getString(TITLE)); try { remote_picture = new getBitMapBigPictureNotification() .execute(gcmStyleObject.getString(URL)).get(); } catch (Exception e) { logger.error( "MFPPushIntentService:generateNotification() - Error while fetching image file."); } if (remote_picture != null) { notificationStyle.bigPicture(remote_picture); } mBuilder = new NotificationCompat.Builder(context); notification = mBuilder.setSmallIcon(icon).setLargeIcon(remote_picture).setAutoCancel(true) .setContentTitle(title) .setContentIntent(PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT)) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentText(msg).setStyle(notificationStyle).build(); } else if (type != null && type.equalsIgnoreCase(BIGTEXT_NOTIFICATION)) { NotificationCompat.BigTextStyle notificationStyle = new NotificationCompat.BigTextStyle(); notificationStyle.setBigContentTitle(ticker); notificationStyle.setSummaryText(gcmStyleObject.getString(TITLE)); notificationStyle.bigText(gcmStyleObject.getString(TEXT)); mBuilder = new NotificationCompat.Builder(context); notification = mBuilder.setSmallIcon(icon).setAutoCancel(true).setContentTitle(title) .setContentIntent(PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT)) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentText(msg).setStyle(notificationStyle).build(); } else if (type != null && type.equalsIgnoreCase(INBOX_NOTIFICATION)) { NotificationCompat.InboxStyle notificationStyle = new NotificationCompat.InboxStyle(); notificationStyle.setBigContentTitle(ticker); notificationStyle.setSummaryText(gcmStyleObject.getString(TITLE)); String lines = gcmStyleObject.getString(LINES).replaceAll("\\[", "").replaceAll("\\]", ""); String[] lineArray = lines.split(","); for (String line : lineArray) { notificationStyle.addLine(line); } mBuilder = new NotificationCompat.Builder(context); notification = mBuilder.setSmallIcon(icon).setAutoCancel(true).setContentTitle(title) .setContentIntent(PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT)) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentText(msg).setStyle(notificationStyle).build(); } notification.flags = Notification.FLAG_AUTO_CANCEL; notificationManager.notify(notificationId, notification); } catch (JSONException e) { logger.error("MFPPushIntentService:generateNotification() - Error while parsing JSON."); } } else { if (androidSDKVersion > 10) { builder.setContentIntent(PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT)).setSmallIcon(icon).setTicker(ticker).setWhen(when) .setAutoCancel(true).setContentTitle(title).setContentText(msg) .setSound(getNotificationSoundUri(context, sound)); if (androidSDKVersion > 15) { int priority = getPriorityOfMessage(message); builder.setPriority(priority); notification = builder.build(); } if (androidSDKVersion > 19) { //As new material theme is very light, the icon is not shown clearly //hence setting the background of icon to black builder.setColor(Color.BLACK); Boolean isBridgeSet = message.getBridge(); if (!isBridgeSet) { // show notification only on current device. builder.setLocalOnly(true); } notification = builder.build(); int receivedVisibility = 1; String visibility = message.getVisibility(); if (visibility != null && visibility.equalsIgnoreCase(MFPPushConstants.VISIBILITY_PRIVATE)) { receivedVisibility = 0; } if (receivedVisibility == Notification.VISIBILITY_PRIVATE && message.getRedact() != null) { builder.setContentIntent(PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT)).setSmallIcon(icon).setTicker(ticker) .setWhen(when).setAutoCancel(true).setContentTitle(title) .setContentText(message.getRedact()) .setSound(getNotificationSoundUri(context, sound)); notification.publicVersion = builder.build(); } } if (androidSDKVersion > 21) { String setPriority = message.getPriority(); if (setPriority != null && setPriority.equalsIgnoreCase(MFPPushConstants.PRIORITY_MAX)) { //heads-up notification builder.setContentText(msg).setFullScreenIntent(PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT), true); notification = builder.build(); } } } else { notification = builder .setContentIntent( PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)) .setSmallIcon(icon).setTicker(ticker).setWhen(when).setAutoCancel(true) .setContentTitle(title).setContentText(msg) .setSound(getNotificationSoundUri(context, sound)).build(); } NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(notificationId, notification); } }