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:net.majorkernelpanic.spydroid.SpydroidActivity.java
public void onDestroy() { super.onDestroy(); // Remove notification ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(0); if (httpServer != null) httpServer.stop();// w w w .j a v a 2 s.c o m if (rtspServer != null) rtspServer.stop(); }
From source file:com.samknows.measurement.test.TestExecutor.java
@SuppressWarnings("deprecation") public void showNotification(String message) { String title = tc.getString(R.string.ntf_title); NotificationManager manager = (NotificationManager) tc.getSystemService(Context.NOTIFICATION_SERVICE); Notification n = new Notification(R.drawable.icon, message, System.currentTimeMillis()); PendingIntent intent = PendingIntent.getService(tc.getServiceContext(), Constants.RC_NOTIFICATION, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT); n.setLatestEventInfo(tc.getServiceContext(), title, message, intent); manager.notify(Constants.NOTIFICATION_ID, n); }
From source file:com.firescar96.nom.GCMIntentService.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private static void Notify(String notificationTitle, String notificationMessage, Bundle data, int id, boolean annoy) { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(thisService) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(notificationTitle) .setContentText(notificationMessage).setAutoCancel(true); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(thisService, MainActivity.class); resultIntent.putExtras(data);/*from w ww.j ava2 s . c o m*/ // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(thisService); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(MainActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); if (annoy) { Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mBuilder.setSound(alarmSound); long[] pattern = { 50, 100, 10, 100, 10, 200 }; mBuilder.setVibrate(pattern); } NotificationManager mNotificationManager = (NotificationManager) thisService .getSystemService(Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(id, mBuilder.build()); }
From source file:anastasoft.rallyvision.activity.MenuPrincipal.java
private void createNotification() { Intent resultIntent = new Intent(this, MenuPrincipal.class); // Because clicking the notification opens a new ("special") activity, there's // no need to create an artificial back stack. PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_notify).setContentTitle(getString(R.string.notification_title)) .setContentText(getString(R.string.notification_text)).setContentInfo(getString(R.string.app_name)) .setAutoCancel(true).setOngoing(true).setTicker(getString(R.string.notification_ticker)); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // mId allows you to setState the notification later on. Notification notification = mBuilder.build(); mNotificationManager.notify(NOTIFICATION_ID, notification); }
From source file:ca.appvelopers.mcgillmobile.util.background.CheckerService.java
/** * Generates a local notification which will redirect the user to the right portion of the app * when clicked/*from w w w. ja v a 2 s . co m*/ * * @param intent The intent to use when clicked * @param message The message to display * @param id The notification Id (to update any existing ones) */ private void createNotification(Intent intent, String message, int id) { //Get the notification manager NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0); NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setSmallIcon(R.mipmap.ic_launcher) .setContentTitle(getString(R.string.app_name)) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)).setContentText(message) .setContentIntent(pendingIntent); manager.notify(id, builder.build()); }
From source file:jieehd.villain.updater.checkInBackground.java
public void notifyUser() { final NotificationManager nm; nm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); CharSequence from = "Villain Updater"; CharSequence message = "New Updates!"; PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, new Intent(), 0); Notification notif = new Notification(R.drawable.updates, "New updates!", System.currentTimeMillis()); notif.setLatestEventInfo(mContext, from, message, contentIntent); nm.notify(1, notif);/* ww w .j a va 2 s .c o m*/ }
From source file:at.flack.receiver.FacebookReceiver.java
@Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras();// w w w . j av a 2s . co m try { if (main instanceof FbMessageOverview && bundle.getString("type").equals("message")) { ((FbMessageOverview) main).addNewMessage( new FacebookMessage(bundle.getString("fb_name"), bundle.getString("fb_message"), bundle.getString("fb_img"), bundle.getLong("fb_id"), bundle.getString("fb_tid"))); } else if (main instanceof FbMessageOverview && bundle.getString("type").equals("readreceipt")) { ((FbMessageOverview) main).changeReadReceipt(bundle.getLong("fb_time"), bundle.getLong("fb_reader")); } else if (main instanceof FbMessageOverview && bundle.getString("type").equals("typ")) { ((FbMessageOverview) main).changeTypingStatus(bundle.getLong("my_id"), bundle.getLong("fb_id"), bundle.getBoolean("fb_from_mobile"), bundle.getInt("fb_status")); } else if (main instanceof FbMessageOverview && bundle.getString("type").equals("img_message")) { ((FbMessageOverview) main).addNewMessage(new FacebookImageMessage(bundle.getString("fb_name"), bundle.getString("fb_image"), bundle.getString("fb_preview"), bundle.getString("fb_img"), bundle.getLong("fb_id"), bundle.getString("fb_tid"))); } else if (bundle.getString("type").equals("read")) { killNotification(context, new MarkAsRead(bundle.getString("fb_tid"), bundle.getBoolean("fb_markas"))); } else if (bundle.getString("type").equals("message") || bundle.getString("type").equals("img_message")) { sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); if (!sharedPrefs.getBoolean("notification_fbs", true)) return; notify = sharedPrefs.getBoolean("notifications", true); vibrate = sharedPrefs.getBoolean("vibration", true); headsup = sharedPrefs.getBoolean("headsup", true); led_color = sharedPrefs.getInt("notification_light", -16776961); boolean all = sharedPrefs.getBoolean("all_fb", true); if (notify == false) return; if (bundle.getLong("fb_id") == bundle.getLong("my_id")) { return; } NotificationCompat.Builder mBuilder = null; boolean use_profile_picture = false; Bitmap profile_picture = null; String origin_name = bundle.getString("fb_name"); try { profile_picture = RoundedImageView.getCroppedBitmap(Bitmap.createScaledBitmap( ProfilePictureCache.getInstance(context).get(origin_name), 200, 200, false), 300); use_profile_picture = true; } catch (Exception e) { use_profile_picture = false; } Resources res = context.getResources(); if (bundle.getString("type").equals("img_message")) { bundle.putString("fb_message", res.getString(R.string.fb_notification_new_image)); } int lastIndex = bundle.getString("fb_message").lastIndexOf("="); if (lastIndex > 0 && Base64.isBase64(bundle.getString("fb_message").substring(0, lastIndex))) { mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.raven_notification_icon).setContentTitle(origin_name) .setColor(0xFF175ea2) .setContentText(res.getString(R.string.sms_receiver_new_encrypted_fb)) .setAutoCancel(true); if (use_profile_picture && profile_picture != null) { mBuilder = mBuilder.setLargeIcon(profile_picture); } else { mBuilder = mBuilder.setLargeIcon(convertToBitmap(origin_name, context.getResources().getDrawable(R.drawable.ic_social_person), 200, 200)); } } else { // normal or handshake if (bundle.getString("fb_message").charAt(0) == '%' && (bundle.getString("fb_message").length() == 10 || bundle.getString("fb_message").length() == 9)) { if (lastIndex > 0 && Base64.isBase64(bundle.getString("fb_message").substring(1, lastIndex))) { mBuilder = new NotificationCompat.Builder(context).setContentTitle(origin_name) .setColor(0xFF175ea2) .setContentText(res.getString(R.string.sms_receiver_handshake_received)) .setSmallIcon(R.drawable.notification_icon).setAutoCancel(true); if (use_profile_picture && profile_picture != null) { mBuilder = mBuilder.setLargeIcon(profile_picture); } else { mBuilder = mBuilder.setLargeIcon(convertToBitmap(origin_name, context.getResources().getDrawable(R.drawable.ic_social_person), 200, 200)); } } else { return; } } else if (bundle.getString("fb_message").charAt(0) == '%' && bundle.getString("fb_message").length() >= 120 && bundle.getString("fb_message").length() < 125) { if (lastIndex > 0 && Base64.isBase64(bundle.getString("fb_message").substring(1, lastIndex))) { mBuilder = new NotificationCompat.Builder(context).setContentTitle(origin_name) .setColor(0xFF175ea2) .setContentText(res.getString(R.string.sms_receiver_handshake_received)) .setSmallIcon(R.drawable.notification_icon).setAutoCancel(true); if (use_profile_picture && profile_picture != null) { mBuilder = mBuilder.setLargeIcon(profile_picture); } else { mBuilder = mBuilder.setLargeIcon(convertToBitmap(origin_name, context.getResources().getDrawable(R.drawable.ic_social_person), 200, 200)); } } else { return; } } else if (all) { // normal message mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.raven_notification_icon).setContentTitle(origin_name) .setColor(0xFF175ea2).setContentText(bundle.getString("fb_message")) .setAutoCancel(true).setStyle(new NotificationCompat.BigTextStyle() .bigText(bundle.getString("fb_message"))); if (use_profile_picture && profile_picture != null) { mBuilder = mBuilder.setLargeIcon(profile_picture); } else { mBuilder = mBuilder.setLargeIcon(convertToBitmap(origin_name, context.getResources().getDrawable(R.drawable.ic_social_person), 200, 200)); } } else { return; } } // } Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mBuilder.setSound(alarmSound); mBuilder.setLights(led_color, 750, 4000); if (vibrate) { mBuilder.setVibrate(new long[] { 0, 100, 200, 300 }); } Intent resultIntent = new Intent(context, MainActivity.class); resultIntent.putExtra("FACEBOOK_NAME", origin_name); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(1, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); if (Build.VERSION.SDK_INT >= 16 && headsup) mBuilder.setPriority(Notification.PRIORITY_HIGH); if (Build.VERSION.SDK_INT >= 21) mBuilder.setCategory(Notification.CATEGORY_MESSAGE); final NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if (!MainActivity.isOnTop) mNotificationManager.notify(8, mBuilder.build()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.teinproductions.tein.papyrosprogress.UpdateCheckReceiver.java
private static void issueBlogNotification(Context context) { String title = context.getString(R.string.notification_title); String message = context.getString(R.string.blog_notification_content); PendingIntent pendingIntent;/*from w w w. j a v a 2s .c o m*/ try { pendingIntent = PendingIntent.getActivity(context, 0, new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.PAPYROS_BLOG_URL)), PendingIntent.FLAG_UPDATE_CURRENT); } catch (Exception e) { e.printStackTrace(); return; } NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setContentTitle(title) .setContentText(message).setContentIntent(pendingIntent) .setSmallIcon(R.mipmap.notification_small_icon) .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher)) .setDefaults(Notification.DEFAULT_ALL).setAutoCancel(true); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(BLOG_NOTIFICATION_ID, builder.build()); }
From source file:at.flack.receiver.FacebookReceiver.java
public void killNotification(Context ctx, MarkAsRead mas) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager nMgr = (NotificationManager) ctx.getSystemService(ns); nMgr.cancel(8);//from w ww . j ava 2 s. c om }
From source file:com.samknows.measurement.test.TestExecutor.java
public void cancelNotification() { NotificationManager manager = (NotificationManager) tc.getSystemService(Context.NOTIFICATION_SERVICE); manager.cancel(Constants.NOTIFICATION_ID); }