List of usage examples for android.app Notification FLAG_NO_CLEAR
int FLAG_NO_CLEAR
To view the source code for android.app Notification FLAG_NO_CLEAR.
Click Source Link
From source file:com.online.fullsail.SaveWebMedia.java
@Override protected void onPreExecute() { Intent intent = new Intent(); final PendingIntent pendingIntent = PendingIntent.getActivity(this.context, 0, intent, 0); notification = new Notification(R.drawable.icon_notification, "Downloading...", System.currentTimeMillis()); notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT; notification.flags |= Notification.FLAG_NO_CLEAR; notification.contentView = new RemoteViews(this.context.getPackageName(), R.layout.download_notify); notification.contentIntent = pendingIntent; notification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon); notification.contentView.setTextViewText(R.id.status_text, "Downloading Content..."); notification.contentView.setProgressBar(R.id.status_progress, 100, 0, false); mNM.notify(timestamp, notification); }
From source file:pylapp.smoothclicker.android.notifiers.StatusBarNotifier.java
/** * Makes a unmovable notification with a dedicated LED color. * This notification is an "on going" one, and should be displayed will the app is clicking. * * @param type - The notification type/*from ww w . ja v a2 s . com*/ * @param params - * <ul> * <li>For CLICK_MADE :params[0] for the X coordinate, params[1] for the Y coordinate</li> * <li>For COUNT_DOWN :params[0] for the leaving time to display</li> * <li>Nothing otherwise</li> * </ul> */ public void makeNotification(NotificationTypes type, long... params) { Logger.d(LOG_TAG, "New notification: " + type); NotificationCompat.Builder b = new NotificationCompat.Builder(mContext); b.setSmallIcon(R.drawable.notification_icon); b.setContentTitle(mContext.getString(R.string.notif_content_title)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) b.setVisibility(Notification.VISIBILITY_PUBLIC); if (type != NotificationTypes.CLICK_MADE && type != NotificationTypes.CLICKS_ON_GOING_BY_SERVICE) { Intent activityToStartOnClick = new Intent(mContext, ClickerActivity.class); activityToStartOnClick.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(mContext, 0, activityToStartOnClick, 0); b.setContentIntent(pi); } NotificationManager nm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); Notification n = null; switch (type) { case CLICKS_ON_GOING_BY_APP: b.setContentText(mContext.getString(R.string.notif_content_text_clicks_on_going_app)); b.setProgress(0, 0, true); b.setLights(0xff9c27b0, 1000, 500); n = b.build(); n.flags |= Notification.FLAG_NO_CLEAR; n.flags |= Notification.FLAG_SHOW_LIGHTS; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) n.flags |= Notification.FLAG_LOCAL_ONLY; nm.notify(NOTIF_CLICK_PROCESS_ON_GOING_BY_APP, n); break; case CLICKS_ON_GOING_STANDALONE: b.setContentText(mContext.getString(R.string.notif_content_text_clicks_on_going_standalone)); b.setProgress(0, 0, true); b.setLights(0xff9c27b0, 1000, 500); n = b.build(); n.flags |= Notification.FLAG_NO_CLEAR; n.flags |= Notification.FLAG_SHOW_LIGHTS; n.flags |= Notification.FLAG_LOCAL_ONLY; nm.notify(NOTIF_CLICK_PROCESS_ON_GOING_STANDALONE, n); break; case CLICKS_ON_GOING_BY_SERVICE: b.setContentText(mContext.getString(R.string.notif_content_text_clicks_on_going_service)); b.setProgress(0, 0, true); b.setLights(0xff9c27b0, 1000, 500); n = b.build(); n.flags |= Notification.FLAG_NO_CLEAR; n.flags |= Notification.FLAG_SHOW_LIGHTS; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) n.flags |= Notification.FLAG_LOCAL_ONLY; nm.notify(NOTIF_CLICK_PROCESS_ON_GOING_BY_SERVICE, n); break; case CLICKS_STOPPED: b.setContentText(mContext.getString(R.string.notif_content_text_clicks_stop)); n = b.build(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) n.flags |= Notification.FLAG_LOCAL_ONLY; nm.notify(NOTIF_CLICK_PROCESS_STOPPED, n); break; case CLICKS_OVER: b.setContentText(mContext.getString(R.string.notif_content_text_clicks_over)); n = b.build(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) n.flags |= Notification.FLAG_LOCAL_ONLY; nm.notify(NOTIF_CLICK_PROCESS_OVER, n); break; case WATCH_OVER: b.setContentText(mContext.getString(R.string.notif_content_text_watch_over)); n = b.build(); n.flags |= Notification.FLAG_LOCAL_ONLY; nm.notify(NOTIF_WATCH_PROCESS_OVER, n); break; case CLICK_MADE: StringBuilder sb = new StringBuilder(); sb.append(mContext.getString(R.string.notif_content_text_click_made)); if (params != null && params.length == 2) { sb.append(" : ").append(params[0]).append(" / ").append(params[1]); } b.setContentText(sb.toString()); n = b.build(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) n.flags |= Notification.FLAG_LOCAL_ONLY; nm.notify(NOTIF_CLICK_MADE, n); break; case SU_GRANTED: b.setContentText(mContext.getString(R.string.notif_content_text_su_granted)); n = b.build(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) n.flags |= Notification.FLAG_LOCAL_ONLY; nm.notify(NOTIF_SU_GRANTED, n); break; case COUNT_DOWN: if (params != null && params.length == 1) { b.setContentText(mContext.getString(R.string.notif_content_text_countdown) + " " + params[0]); } else { b.setContentText(mContext.getString(R.string.notif_content_text_countdown)); } n = b.build(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) n.flags |= Notification.FLAG_NO_CLEAR; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) n.flags |= Notification.FLAG_LOCAL_ONLY; nm.notify(NOTIF_COUNT_DOWN, n); break; } }
From source file:mdn.vtvsport.GcmIntentService.java
private static void generateNotification(Context context, GCMInfo info) { /*//from w w w . j a v a 2s . c o m int icon = R.drawable.icon_small; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, info.getMessage(), when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, BaseSlideMenuActivity.class); notificationIntent.putExtra(GCMBUNDLE_ID, info.getItemId()); notificationIntent.putExtra(GCMBUNDLE_TYPE, info.getType()); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, title, info.getMessage(), intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); */ String message = info.getMessage(); Intent notificationIntent = new Intent(context, BaseSlideMenuActivity.class); notificationIntent.putExtra(GCMBUNDLE_ID, info.getItemId()); notificationIntent.putExtra(GCMBUNDLE_TYPE, info.getType()); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);//FLAG_ACTIVITY_NEW_TASK TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(BaseSlideMenuActivity.class); stackBuilder.addNextIntent(notificationIntent); int id = -1; try { id = Integer.parseInt(info.getMessageId()); } catch (Exception e) { // TODO: handle exception } PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(id, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setTicker(message) .setSmallIcon(R.drawable.icon_small).setContentTitle(HomeFragment.APP_NAME_1) .setContentText(message).setAutoCancel(true).setContentIntent(resultPendingIntent) .setStyle(new NotificationCompat.BigTextStyle().setSummaryText(message)); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = mBuilder.build(); notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_AUTO_CANCEL; mNotificationManager.notify(id, notification); }
From source file:org.envirocar.app.application.service.BackgroundServiceImpl.java
private void createForegroundNotification(int stringResource) { CharSequence string = getResources().getText(stringResource); Intent intent = new Intent(this, MainActivity.class); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); Notification note = new NotificationCompat.Builder(getApplicationContext()).setContentTitle("enviroCar") .setContentText(string).setContentIntent(pIntent).setSmallIcon(R.drawable.dashboard).build(); note.flags |= Notification.FLAG_NO_CLEAR; startForeground(BG_NOTIFICATION_ID, note); }
From source file:cm.aptoide.pt.DownloadQueueService.java
private void setNotification(int apkidHash, int progress) { String apkid = notifications.get(apkidHash).get("apkid"); int size = Integer.parseInt(notifications.get(apkidHash).get("intSize")); String version = notifications.get(apkidHash).get("version"); RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.download_notification); contentView.setImageViewResource(R.id.download_notification_icon, R.drawable.ic_notification); contentView.setTextViewText(R.id.download_notification_name, getString(R.string.download_alrt) + " " + apkid + " v." + version); contentView.setProgressBar(R.id.download_notification_progress_bar, size * KBYTES_TO_BYTES, progress, false);/*from ww w . j a va 2 s . c o m*/ Intent onClick = new Intent(); onClick.setClassName("cm.aptoide.pt", "cm.aptoide.pt"); onClick.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); onClick.setAction("cm.aptoide.pt.FROM_NOTIFICATION"); // The PendingIntent to launch our activity if the user selects this notification PendingIntent onClickAction = PendingIntent.getActivity(context, 0, onClick, 0); Notification notification = new Notification(R.drawable.ic_notification, getString(R.string.download_alrt) + " " + apkid, System.currentTimeMillis()); notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; notification.contentView = contentView; // Set the info for the notification panel. notification.contentIntent = onClickAction; // notification.setLatestEventInfo(this, getText(R.string.app_name), getText(R.string.add_repo_text), contentIntent); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Send the notification. // We use the position because it is a unique number. We use it later to cancel. notificationManager.notify(apkidHash, notification); // Log.d("Aptoide-DownloadQueueService", "Notification Set"); }
From source file:com.achep.acdisplay.notifications.OpenNotification.java
/** * Convenience method to check the notification's flags for * either {@link Notification#FLAG_ONGOING_EVENT} or * {@link Notification#FLAG_NO_CLEAR}.//from www . j a v a2s. c om */ public boolean isClearable() { return ((mNotification.flags & Notification.FLAG_ONGOING_EVENT) == 0) && ((mNotification.flags & Notification.FLAG_NO_CLEAR) == 0); }
From source file:com.quarterfull.newsAndroid.services.DownloadImagesService.java
private Notification BuildNotification() { Intent intentNewsReader = new Intent(this, NewsReaderListActivity.class); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intentNewsReader, 0); notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationDownloadImages = new NotificationCompat.Builder(this) .setContentTitle(getResources().getString(R.string.app_name)) .setContentText("Downloading images for offline usage").setSmallIcon(R.drawable.ic_notification) .setContentIntent(pIntent).setOngoing(true); Notification notify = mNotificationDownloadImages.build(); //Hide the notification after its selected notify.flags |= Notification.FLAG_AUTO_CANCEL; notify.flags |= Notification.FLAG_NO_CLEAR; return notify; }
From source file:mf.stickybit.android.trackergps.LoginActivity.java
public void checkLogin(boolean isLogin) { if (isLogin) { NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.cancelAll(); final Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); Notification notification = new NotificationCompat.Builder(this) .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0)) .setSmallIcon(R.drawable.trackergps_icon) .setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.trackergps_icon)) .setTicker("TrackerGPS").setWhen(System.currentTimeMillis()).setAutoCancel(false) .setContentTitle("TrackerGPS esta ejecutandose").setContentText("A la espera...").build(); notification.flags |= Notification.FLAG_NO_CLEAR; notificationManager.notify(0, notification); moveTaskToBack(true);//from w w w . j a va 2 s .c o m } else { if ((getCantidadFails() == (getResources().getInteger(R.integer.login_max_retry)))) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Fallo " + String.valueOf( (int) getApplicationContext().getResources().getInteger(R.integer.login_max_retry)) + " veces al iniciar sesin.") .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }); builder.show(); } else { clear(); mPasswordView.setError(getString(R.string.error_incorrect_password)); mPasswordView.requestFocus(); } } }
From source file:com.gsma.rcs.notif.RcsServiceNotifManager.java
private void addImsConnectionNotification(boolean connected, String label) { String title = this.getString(R.string.notification_title_rcs_service); Notification notif = buildImsConnectionNotification(null, title, label, connected); notif.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_FOREGROUND_SERVICE; NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIF_ID, notif); }
From source file:org.addhen.smssync.util.Util.java
/** * Show notification/*w w w . j a v a 2 s. c o m*/ */ public static void showNotification(Context context) { NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Intent baseIntent = new Intent(context, MessagesTabActivity.class); baseIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Notification notification = new Notification(R.drawable.icon, context.getString(R.string.status), System.currentTimeMillis()); notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR; PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, baseIntent, 0); notification.setLatestEventInfo(context, context.getString(R.string.app_name), context.getString(R.string.notification_summary), pendingIntent); notificationManager.notify(NOTIFY_RUNNING, notification); }