List of usage examples for android.content Context NOTIFICATION_SERVICE
String NOTIFICATION_SERVICE
To view the source code for android.content Context NOTIFICATION_SERVICE.
Click Source Link
From source file:azzaoui.sociadee.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w w w .ja va 2 s. c om*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.pp_swag).setContentTitle("GCM Message").setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.partner.common.updater.ApkDownloadUtil.java
/** * ?/*from w w w . j ava2 s . co m*/ * @param context * @param targetClass */ private void showAppDownloadNotify(Context context, Class<?> parentClass, Class<?> targetClass) { mNotifyManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // show notify Intent notifyIntent = new Intent(context, targetClass); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); // Adds the back stack if (parentClass != null) { stackBuilder.addNextIntent(new Intent(context, parentClass)); } // Adds the Intent to the top of the stack stackBuilder.addNextIntent(notifyIntent); // Gets a PendingIntent containing the entire back stack PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder = new NotificationCompat.Builder(context); mBuilder.setContentTitle(appName).setSmallIcon(R.drawable.ic_launcher) .setContentIntent(resultPendingIntent); mBuilder.setProgress(100, 0, false); mNotifyManager.notify(appName.hashCode(), mBuilder.build()); }
From source file:com.otaupdater.utils.KernelInfo.java
public static void clearUpdateNotif(Context ctx) { NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(Config.KERNEL_NOTIF_ID);//from w ww . j a va2 s. com }
From source file:de.wikilab.android.friendica01.FileUploadService.java
private void showSuccessMsg(Context ctx) { NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); //Instantiate the Notification: int icon = R.drawable.arrow_up; CharSequence tickerText = "Upload succeeded!"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.flags |= Notification.FLAG_AUTO_CANCEL; /*//from ww w . j a v a 2s.com //TODO!!! //Define the Notification's expanded message and Intent: Context context = getApplicationContext(); CharSequence contentTitle = "Upload successful, click to show details!"; CharSequence contentText = targetFilename; Intent notificationIntent = new Intent(this, FilePreview.class); Bundle b = new Bundle(); b.putInt("cid", clipId); notificationIntent.putExtras(b); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); */ //Define the Notification's expanded message and Intent: Context context = getApplicationContext(); PendingIntent nullIntent = PendingIntent.getActivity(context, 0, new Intent(), 0); notification.setLatestEventInfo(context, tickerText, "Click to dismiss", nullIntent); //Pass the Notification to the NotificationManager: mNotificationManager.notify(UPLOAD_SUCCESS_ID, notification); //Toast.makeText(ctx, "Upload failed, please retry:\n" + txt, Toast.LENGTH_LONG).show(); }
From source file:com.NotifyMe.GcmIntentService.java
private void sendNotification(String msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle("NotifyMe").setAutoCancel(true) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg) .setDefaults(Notification.DEFAULT_VIBRATE).setOnlyAlertOnce(true); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.imobilize.blogposts.gcmnotifications.GcmIntentService.java
private void sendNotification(String articleDataString) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); JSONObject articleDataJson = null;/*from ww w . ja va 2 s . com*/ try { articleDataJson = new JSONObject(articleDataString); } catch (JSONException e) { e.printStackTrace(); } Intent intentForArticleActivity = new Intent(this, ArticleActivity.class); String notificationMessage = null; try { intentForArticleActivity.putExtra(Constants.ARTICLE_TITLE, articleDataJson.getString("title")); intentForArticleActivity.putExtra(Constants.ARTICLE_METADATA, "Posted by " + articleDataJson.getString("author") + " on " + articleDataJson.getString("creationDate")); intentForArticleActivity.putExtra(Constants.ARTICLE_CONTENT, articleDataJson.getString("content")); intentForArticleActivity.putExtra(Constants.ARTICLE_KEY, articleDataJson.getString("key")); notificationMessage = "Read our new article from category " + articleDataJson.getString("categories") + " called '" + articleDataJson.getString("title") + "'"; } catch (JSONException e) { e.printStackTrace(); } PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intentForArticleActivity, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_gcm) .setAutoCancel(true).setContentTitle("BLOGPOSTS") .setStyle(new NotificationCompat.BigTextStyle().bigText(notificationMessage)) .setContentText(notificationMessage); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.swisscom.safeconnect.utils.gcm.GcmBroadcastReceiver.java
private void sendNotification(String title, String msg, Context ctx) { mNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancelAll();//w w w.ja va 2 s .c o m Intent intentSubscriptions = new Intent(ctx, DashboardActivity.class); intentSubscriptions.putExtra(DashboardActivity.KEY_OPEN_SUBSCRIPTIONS, true); // without FLAG_CANCEL_CURRENT the parameters don't arrive PendingIntent subscriptionsIntent = PendingIntent.getActivity(ctx, 0, intentSubscriptions, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ctx) //.setDefaults(Notification.DEFAULT_ALL) // with DEFAULT_ALL it requires VIBRATE permissions! (on HTC One S 4.1.1) .setSmallIcon(R.drawable.ic_notif).setContentTitle(title) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg) .addAction(R.drawable.ic_subscription_shoppingcart, ctx.getString(R.string.push_extend), subscriptionsIntent); mBuilder.setContentIntent(subscriptionsIntent); mBuilder.setAutoCancel(true); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:ca.rmen.android.networkmonitor.app.service.NetMonNotification.java
public static void dismissEmailFailureNotification(Context context) { NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_ID_FAILED_EMAIL); }
From source file:com.ecocitizen.service.SensorMapUploaderService.java
@Override public void onCreate() { super.onCreate(); if (D)// w w w . j av a 2 s .co m Log.d(TAG, "+++ ON CREATE +++"); String ns = Context.NOTIFICATION_SERVICE; mNotificationManager = (NotificationManager) getSystemService(ns); updateStatus(Status.STANDBY); }
From source file:com.versul.newbornswatcher.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.// www .j a v a 2 s .co m */ private void sendNotification(String message) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.eye); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(android.R.drawable.ic_dialog_alert) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_large)) .setContentTitle("Newborns Watcher").setContentText(message).setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }