List of usage examples for android.app Notification Notification
@Deprecated public Notification(int icon, CharSequence tickerText, long when)
From source file:org.transdroid.service.UpdateService.java
private void newNotification(String ticker, String title, String text, String downloadUrl, int notifyID) { // Use the alarm service settings for the notification sound/vibrate/colour SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); AlarmSettings settings = Preferences.readAlarmSettings(prefs); // Set up an intent that will initiate a download of the new version Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(downloadUrl)); // Create a new notification Notification newNotification = new Notification(R.drawable.icon_notification, ticker, System.currentTimeMillis()); newNotification.flags = Notification.FLAG_AUTO_CANCEL; newNotification.setLatestEventInfo(getApplicationContext(), title, text, PendingIntent.getActivity(getApplicationContext(), notifyID, i, 0)); // Get the system notification manager, if not done so previously if (notificationManager == null) { notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); }/*from w w w . j ava2s .c o m*/ // If sound enabled add to notification if (settings.getAlarmPlaySound() && settings.getAlarmSoundURI() != null) { newNotification.sound = Uri.parse(settings.getAlarmSoundURI()); } // If vibration enabled add to notification if (settings.getAlarmVibrate()) { newNotification.defaults = Notification.DEFAULT_VIBRATE; } // Add coloured light; defaults to 0xff7dbb21 newNotification.ledARGB = settings.getAlarmColour(); newNotification.ledOnMS = 600; newNotification.ledOffMS = 1000; newNotification.flags |= Notification.FLAG_SHOW_LIGHTS; // Send notification notificationManager.notify(notifyID, newNotification); }
From source file:be.vbsteven.bmtodesk.BackgroundSharingService.java
/** * shows notification when the sending succeeded *//*w w w . ja v a 2 s . c om*/ private void showSuccessfulSend() { if (Global.isHideConfirmation(this)) { nManager.cancelAll(); } else { Notification n = new Notification(R.drawable.icon, "Sending bookmark successful", System.currentTimeMillis()); n.flags = Notification.FLAG_AUTO_CANCEL; Intent i = new Intent(this, AfterSuccessfulSendActivity.class); i.putExtra(Global.EXTRA_TITLE, title); i.putExtra(Global.EXTRA_URL, url); PendingIntent p = PendingIntent.getActivity(this, 4, i, 0); n.setLatestEventInfo(this, "Bookmark to Desktop", "Sending bookmark successful", p); nManager.notify(3, n); } }
From source file:ro.weednet.contactssync.syncadapter.SyncAdapter.java
@SuppressWarnings("deprecation") public void showNotificationMessage(String tickerText, String title, String desc) { if (!ContactsSync.getInstance().getShowNotifications()) { return;//from w ww.jav a 2s. co m } NotificationManager mNotificationManager = (NotificationManager) getContext() .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.icon, tickerText, System.currentTimeMillis()); Context context = ContactsSync.getInstance().getApplicationContext(); Intent notificationIntent = new Intent(context, Preferences.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, desc, contentIntent); mNotificationManager.notify(1, notification); }
From source file:com.fordemobile.livepaintings.FragmentPagerSupport.java
public void notifyUser(int titleId, int messageId) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); int icon = R.drawable.icon; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, getString(titleId), when); Context context = getApplicationContext(); CharSequence contentTitle = getString(titleId); CharSequence contentText = getString(messageId); Intent notificationIntent = new Intent(this, FragmentPagerSupport.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); mNotificationManager.notify(0, notification); }
From source file:com.arisprung.tailgate.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *//*from ww w . j av a2 s. co m*/ private static void generateNotification(Context context, MessageBean message) { // Intent notificationIntent = new Intent(ctx, MainActivity.class); // PendingIntent contentIntent = PendingIntent.getActivity(ctx, // 10, notificationIntent, // PendingIntent.FLAG_CANCEL_CURRENT); // // NotificationManager nm = (NotificationManager) ctx // .getSystemService(Context.NOTIFICATION_SERVICE); // // Resources res = ctx.getResources(); // Notification.Builder builder = new Notification.Builder(ctx); // // Bitmap profile = TailGateUtility.getUserPic(message.getFaceID()); // // builder.setContentIntent(contentIntent) // .setSmallIcon(R.drawable.ic_launcher) // .setLargeIcon(profile) // .setTicker(res.getString(R.string.app_name)) // .setWhen(System.currentTimeMillis()) // .setAutoCancel(true) // .setContentTitle(message.getUserName()) // .setContentText(message.getMessage()); // Notification n = builder.build(); // // nm.notify(0, n); int icon = R.drawable.fanatic_icon_72px; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message.getMessage(), when); String name = message.getUserName(); Intent notificationIntent = new Intent(context, MainActivity.class); // 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, 0); notification.setLatestEventInfo(context, name, message.getMessage(), intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); }
From source file:net.helff.wificonnector.WifiConnectivityService.java
protected void sendNotification(String msg) { Log.i(TAG, "send notification: " + msg); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.launchericon, msg, System.currentTimeMillis()); Intent intent = new Intent(this, WifiConnectorActivity.class); intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); notification.setLatestEventInfo(this.getApplicationContext(), "WifiConnector", msg, pendingIntent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(1, notification); }
From source file:org.addhen.smssync.util.Util.java
/** * Show a notification// w ww.j a v a 2 s . c o m * * @param String * message to display * @param String * notification title */ public static void showFailNotification(Context context, String message, String notification_title) { 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()); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, baseIntent, 0); notification.setLatestEventInfo(context, notification_title, message, pendingIntent); notificationManager.notify(NOTIFY_RUNNING, notification); }
From source file:org.droidkit.app.UpdateService.java
private void notifyUser(String json) { Intent intent = new Intent(this, UpdateActivity.class); intent.putExtra("json", json); String desc = "Update available for " + getString(getApplicationInfo().labelRes); PendingIntent pending = PendingIntent.getActivity(this, 0, intent, 0); Notification n = new Notification(android.R.drawable.stat_sys_download_done, "Update available", System.currentTimeMillis()); n.setLatestEventInfo(this, "Update Available", desc, pending); mNotificationManager.notify("Update Available", UPDATE_SERVICE_ID, n); }
From source file:kr.co.bettersoft.checkmileage.activities.GCMIntentService.java
/** * generateNotification/*ww w. j a v a2 s.co m*/ * Issues a notification to inform the user that server has sent a message. * @param context * @param message * @return */ private void generateNotification(Context context, String message) { int icon = R.drawable.ic_stat_gcm; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); // sdf String title = context.getString(R.string.app_name); String mileageUpdateStr = context.getString(R.string.mileage_noti); Intent notificationIntent; /* * MILEAGE : ? ?? ? ???. * MARKETING : ?? ? ?. * Check Mileage ?. : test .. * * <string name="gcm_new_msgkkk"> </string> */ String new_msg = " "; if (message.equals(new_msg)) { Log.d(TAG, "new msg - test"); notificationIntent = new Intent(context, DummyActivity.class); // notificationIntent.putExtra("RunMode", "TEST"); // ?? ? . ?? .. ? .. notificationIntent.putExtra("RunMode", "MILEAGE"); // // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK // | Intent.FLAG_ACTIVITY_CLEAR_TOP // | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); // }else if(message.contains("MILEAGE")){ // }else if(message.contains(mileageUpdateStr)){ // ?? ?. () } else if (message.equals(mileageUpdateStr)) { // ?? ?. (). Log.d(TAG, "update mileage"); MyMileagePageActivity.searched = false; // notificationIntent = new Intent(context, MainActivity.class); // ? ? ?.. notificationIntent = new Intent(context, DummyActivity.class); notificationIntent.putExtra("RunMode", "MILEAGE"); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK // | Intent.FLAG_ACTIVITY_CLEAR_TOP // | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); } else if (message.equals("MARKETING")) { Log.d(TAG, "noti event push"); // notificationIntent = new Intent(context, MainActivity.class); // ? ? ? ? .. notificationIntent = new Intent(context, DummyActivity.class); notificationIntent.putExtra("RunMode", "MARKETING"); notificationIntent.putExtra("MESSAGE", "New Event"); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK // | Intent.FLAG_ACTIVITY_CLEAR_TOP // | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); } else { // ?. Log.d(TAG, "noti event push"); // notificationIntent = new Intent(context, MainActivity.class); // ? ? ? ? .. notificationIntent = new Intent(context, DummyActivity.class); notificationIntent.putExtra("RunMode", "MARKETING"); notificationIntent.putExtra("MESSAGE", message); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK // | Intent.FLAG_ACTIVITY_CLEAR_TOP // | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); } }