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.tenforwardconsulting.cordova.bgloc.AbstractLocationService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i(TAG, "Received start id " + startId + ": " + intent); if (intent != null) { config = (Config) intent.getParcelableExtra("config"); activity = intent.getStringExtra("activity"); Log.d(TAG, "Got activity" + activity); // Build a Notification required for running service in foreground. NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentTitle(config.getNotificationTitle()); builder.setContentText(config.getNotificationText()); builder.setSmallIcon(android.R.drawable.ic_menu_mylocation); if (config.getNotificationIcon() != null) { builder.setSmallIcon(getPluginResource(config.getSmallNotificationIcon())); builder.setLargeIcon(BitmapFactory.decodeResource(getApplication().getResources(), getPluginResource(config.getLargeNotificationIcon()))); }//from w w w . jav a 2 s . co m if (config.getNotificationIconColor() != null) { builder.setColor(this.parseNotificationIconColor(config.getNotificationIconColor())); } setClickEvent(builder); Notification notification = builder.build(); notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_FOREGROUND_SERVICE | Notification.FLAG_NO_CLEAR; startForeground(startId, notification); } Log.i(TAG, config.toString()); Log.i(TAG, "- activity: " + activity); //We want this service to continue running until it is explicitly stopped return START_STICKY; }
From source file:com.andrewreitz.encryptedcamera.di.module.AndroidModule.java
@Provides @Singleton/*from w w w . jav a2 s . c o m*/ @EncryptionErrorNotification Notification provideEncryptionErrorNotification() { Notification notification = new NotificationCompat.Builder(application) // .setContentTitle(application.getString(R.string.error_encrypting)) // .setContentText(application.getString(R.string.error_encrypting_photo)) // .setSmallIcon(R.drawable.ic_unlocked) //TODO New Icon .setAutoCancel(true) // .build(); notification.flags |= Notification.FLAG_NO_CLEAR; return notification; }
From source file:pw.thedrhax.util.Notify.java
public Notify show() { if (!enabled) return this; Notification notification = build(); if (locked && context instanceof Service) { ((Service) context).startForeground(id, notification); return this; }// w ww .j a v a 2s .co m if (locked) { notification.flags |= Notification.FLAG_NO_CLEAR; } nm.notify(id, build()); return this; }
From source file:com.sspai.dkjt.service.GenerateFrameService.java
@Override public void startingImage(Bitmap screenshot) { // Create the large notification icon int imageWidth = screenshot.getWidth(); int imageHeight = screenshot.getHeight(); int iconSize = resources.getDimensionPixelSize(android.R.dimen.notification_large_icon_height); final int shortSide = imageWidth < imageHeight ? imageWidth : imageHeight; // Check for if config is null, http://crashes.to/s/dd0857c8648 Bitmap preview = Bitmap.createBitmap(shortSide, shortSide, screenshot.getConfig() == null ? Bitmap.Config.ARGB_8888 : screenshot.getConfig()); Canvas c = new Canvas(preview); Paint paint = new Paint(); ColorMatrix desat = new ColorMatrix(); desat.setSaturation(0.25f);//from ww w. ja v a 2 s. co m paint.setColorFilter(new ColorMatrixColorFilter(desat)); Matrix matrix = new Matrix(); matrix.postTranslate((shortSide - imageWidth) / 2, (shortSide - imageHeight) / 2); c.drawBitmap(screenshot, matrix, paint); c.drawColor(0x40FFFFFF); Bitmap croppedIcon = Bitmap.createScaledBitmap(preview, iconSize, iconSize, true); Intent nullIntent = new Intent(this, MainActivity.class); nullIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationBuilder = new NotificationCompat.Builder(this) .setTicker(resources.getString(R.string.screenshot_saving_ticker)) .setContentTitle(resources.getString(R.string.screenshot_saving_title)) .setSmallIcon(R.drawable.ic_actionbar_logo) .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(preview)) .setContentIntent(PendingIntent.getActivity(this, 0, nullIntent, 0)) .setWhen(System.currentTimeMillis()).setProgress(0, 0, true).setLargeIcon(croppedIcon); Notification n = notificationBuilder.build(); n.flags |= Notification.FLAG_NO_CLEAR; notificationManager.notify(DFG_NOTIFICATION_ID, n); }
From source file:org.bfr.periodicquery.PeriodicQueryService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { // The intent to launch when the user clicks the expanded notification Intent launchIntent = new Intent(this, StartStopActivity.class); launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendIntent = PendingIntent.getActivity(this, 0, launchIntent, 0); // This constructor is deprecated. Use Notification.Builder instead Notification notice = new Notification(R.drawable.ic_launcher, "Periodic Query", System.currentTimeMillis()); // This method is deprecated. Use Notification.Builder instead. notice.setLatestEventInfo(this, "Periodic Query", "Periodic Query", pendIntent); notice.flags |= Notification.FLAG_NO_CLEAR; startForeground(1234, notice);/*from w w w. j a va 2s .c o m*/ return START_STICKY; }
From source file:edu.umich.si.inteco.minuku.manager.MinukuNotificationManager.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "OnStartCommand"); if (mNotificationManager == null) { mNotificationManager = (android.app.NotificationManager) getSystemService(Service.NOTIFICATION_SERVICE); }//from w w w. j a v a 2 s . c om AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE); alarm.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + Constants.PROMPT_SERVICE_REPEAT_MILLISECONDS, PendingIntent.getService(this, 0, new Intent(this, MinukuNotificationManager.class), 0)); Notification note = new Notification.Builder(getBaseContext()) .setContentTitle(Constants.getInstance().getAppName()) .setContentText(Constants.getInstance().getRunningAppDeclaration()) .setSmallIcon(R.drawable.self_reflection).setAutoCancel(false).build(); note.flags |= Notification.FLAG_NO_CLEAR; startForeground(42, note); checkRegisteredNotifications(); return START_STICKY_COMPATIBILITY; }
From source file:com.tenforwardconsulting.cordova.bgloc.LocationService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i(TAG, "Received start id " + startId + ": " + intent); // config = Config.fromByteArray(intent.getByteArrayExtra("config")); if (intent.hasExtra("config")) { config = (Config) intent.getParcelableExtra("config"); } else {/*from w ww. j a v a 2 s . co m*/ config = new Config(); } ServiceProviderFactory spf = new ServiceProviderFactory(this, config); provider = spf.getInstance(config.getServiceProvider()); provider.onCreate(); if (config.getStartForeground()) { // Build a Notification required for running service in foreground. NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentTitle(config.getNotificationTitle()); builder.setContentText(config.getNotificationText()); if (config.getSmallNotificationIcon() != null) { builder.setSmallIcon(getPluginResource(config.getSmallNotificationIcon())); } else { builder.setSmallIcon(android.R.drawable.ic_menu_mylocation); } if (config.getLargeNotificationIcon() != null) { builder.setLargeIcon(BitmapFactory.decodeResource(getApplication().getResources(), getPluginResource(config.getLargeNotificationIcon()))); } if (config.getNotificationIconColor() != null) { builder.setColor(this.parseNotificationIconColor(config.getNotificationIconColor())); } setClickEvent(builder); Notification notification = builder.build(); notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_FOREGROUND_SERVICE | Notification.FLAG_NO_CLEAR; startForeground(startId, notification); } provider.startRecording(); //We want this service to continue running until it is explicitly stopped return START_REDELIVER_INTENT; }
From source file:org.jitsi.service.osgi.OSGiService.java
/** * Start the service in foreground and creates shows general notification * icon./*from w w w . java 2s. c o m*/ */ private void showIcon() { //The intent to launch when the user clicks the expanded notification PendingIntent pendIntent = JitsiApplication.getJitsiIconIntent(); Resources res = getResources(); String title = res.getString(R.string.app_name); NotificationCompat.Builder nBuilder = new NotificationCompat.Builder(this).setContentTitle(title) .setWhen(System.currentTimeMillis()).setSmallIcon(R.drawable.notificationicon); nBuilder.setContentIntent(pendIntent); Notification notice = nBuilder.build(); notice.flags |= Notification.FLAG_NO_CLEAR; this.startForeground(GENERAL_NOTIFICATION_ID, notice); running_foreground = true; }
From source file:org.jitsi.android.gui.util.AndroidUtils.java
/** * Shows an alert dialog for the given context and a title given by * <tt>titleId</tt> and message given by <tt>messageId</tt>. * * @param context the android <tt>Context</tt> * @param notificationID the identifier of the notification to update * @param title the title of the message * @param message the message//from w w w . java 2 s.c o m * @param date the date on which the event corresponding to the notification * happened */ public static void updateGeneralNotification(Context context, int notificationID, String title, String message, long date) { // Filter out the same subsequent notifications if (lastNotificationText != null && lastNotificationText.equals(message)) { return; } NotificationCompat.Builder nBuilder = new NotificationCompat.Builder(context).setContentTitle(title) .setContentText(message).setWhen(date).setSmallIcon(R.drawable.notificationicon); nBuilder.setContentIntent(JitsiApplication.getJitsiIconIntent()); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = nBuilder.build(); notification.flags = Notification.FLAG_ONLY_ALERT_ONCE & Notification.FLAG_FOREGROUND_SERVICE & Notification.FLAG_NO_CLEAR; // mId allows you to update the notification later on. mNotificationManager.notify(notificationID, notification); lastNotificationText = message; }
From source file:org.cloudsdale.android.faye.CloudsdaleFayeService.java
private Notification makeNotification(String title, String content) { Bitmap icon = BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.color_icon); Notification note = new NotificationCompat.Builder(getApplicationContext()).setContentTitle(title) .setContentText(content).setSmallIcon(R.drawable.color_icon).setLargeIcon(icon).getNotification(); Intent i = new Intent(this, HomeActivity.class); PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0); note.flags |= Notification.FLAG_NO_CLEAR; return note;//from w w w .ja va 2 s . c o m }