List of usage examples for android.app Notification setLatestEventInfo
@Deprecated public void setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent)
From source file:de.ub0r.android.websms.connector.common.Utils.java
/** * Show update notification./*from w w w .ja va2 s. c o m*/ * * @param context * {@link Context} * @param pkg * package */ public static void showUpdateNotification(final Context context, final String pkg) { Notification n = new Notification(android.R.drawable.stat_sys_warning, context.getString(R.string.update_title), 0); n.flags = Notification.FLAG_AUTO_CANCEL; PendingIntent pi = PendingIntent.getActivity(context, 0, new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + pkg)), PendingIntent.FLAG_UPDATE_CURRENT); n.setLatestEventInfo(context, context.getString(R.string.update_title), context.getString(R.string.update_message), pi); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(0, n); }
From source file:com.securecomcode.text.service.KeyCachingService.java
private void foregroundServiceLegacy() { Notification notification = new Notification(R.drawable.icon_cached, getString(R.string.KeyCachingService_textsecure_passphrase_cached), System.currentTimeMillis()); notification.setLatestEventInfo(getApplicationContext(), getString(R.string.KeyCachingService_passphrase_cached), getString(R.string.KeyCachingService_textsecure_passphrase_cached), buildLaunchIntent()); notification.tickerText = null;/*from w w w. j a v a2s. c o m*/ stopForeground(true); startForeground(SERVICE_RUNNING_ID, notification); }
From source file:can.yrt.onebusaway.tripservice.NotifierTask.java
@SuppressWarnings("deprecation") private void setLatestInfo(Notification notification, String stopId, String routeId, long timeDiff) { final String title = mContext.getString(R.string.app_name); final PendingIntent intent = PendingIntent.getActivity(mContext, 0, new ArrivalsListActivity.Builder(mContext, stopId).getIntent(), PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(mContext, title, getNotifyText(routeId, timeDiff), intent); }
From source file:net.ben.subsonic.androidapp.util.Util.java
public static void showErrorNotification(final Context context, Handler handler, String title, Exception error) {//from w w w .jav a 2 s.com final NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); StringBuilder text = new StringBuilder(); if (error.getMessage() != null) { text.append(error.getMessage()).append(" ("); } text.append(error.getClass().getSimpleName()); if (error.getMessage() != null) { text.append(")"); } // Set the icon, scrolling text and timestamp final Notification notification = new Notification(android.R.drawable.stat_sys_warning, title, System.currentTimeMillis()); notification.flags |= Notification.FLAG_AUTO_CANCEL; // The PendingIntent to launch our activity if the user selects this notification Intent intent = new Intent(context, ErrorActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Constants.INTENT_EXTRA_NAME_ERROR, title + ".\n\n" + text); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, title, text, contentIntent); // Send the notification. handler.post(new Runnable() { @Override public void run() { notificationManager.cancel(Constants.NOTIFICATION_ID_ERROR); notificationManager.notify(Constants.NOTIFICATION_ID_ERROR, notification); } }); }
From source file:com.riksof.a320.c2dm.common.C2DMReceiver.java
@Override protected void onMessage(Context contxt, Intent intent) { String unValidatedURL = intent.getStringExtra("payload"); Log.w("C2DMReceiver", unValidatedURL); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); int icon = R.drawable.ic_launcher; // icon from resources CharSequence tickerText = "You got message !!!"; // ticker-text long when = System.currentTimeMillis(); // notification time Context context = getApplicationContext(); // application Context Intent notificationIntent = new Intent(this, PushEndpointDemo.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); CharSequence contentTitle = "Norification Received !"; // the next two lines initialize the Notification, using the configurations above Notification notification = new Notification(icon, tickerText, when); notification.defaults |= Notification.DEFAULT_LIGHTS; notification.ledARGB = 0xff00ff00;//w w w . j a v a2 s .c o m notification.ledOnMS = 300; notification.ledOffMS = 1000; notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.setLatestEventInfo(context, contentTitle, unValidatedURL, contentIntent); notificationManager.notify(10001, notification); Cache.getInstance().remove(unValidatedURL); FileCache fc = new FileCache(context); fc.clear(); Log.w("C2DMReceiver", "finish"); }
From source file:com.pixmob.r2droid.DeviceRegistrationService.java
private void startForeground() { nm.cancel(STATUS_UPDATE_DONE);/*from w w w. jav a 2 s . c om*/ final Notification notification = new Notification(R.drawable.ic_stat_icon, getString(R.string.updating_device), System.currentTimeMillis()); notification.setLatestEventInfo(this, getString(R.string.app_name), getString(R.string.updating_device), dashboardIntent); startForeground(STATUS_UPDATE_FOREGROUND, notification); }
From source file:be.vbsteven.bmtodesk.BackgroundSharingService.java
/** * shows the progress notification/*from w w w. j av a 2s.co m*/ */ private void showProgress() { Notification n = new Notification(R.drawable.icon, "Sending bookmark to server...", System.currentTimeMillis()); Intent i = new Intent(this, MainActivity.class); // contentintent is required. so redirect to mainpage PendingIntent contentIntent = PendingIntent.getActivity(this, 1, i, 0); n.setLatestEventInfo(this, "Bookmark to Desktop", "Sending bookmark to server...", contentIntent); nManager.notify(2, n); }
From source file:com.android.python27.ScriptService.java
@Override protected Notification createNotification() { Notification notification = new Notification(R.drawable.icon, this.getString(R.string.loading), System.currentTimeMillis()); // This contentIntent is a noop. PendingIntent contentIntent = PendingIntent.getService(this, 0, new Intent(), 0); notification.setLatestEventInfo(this, this.getString(R.string.app_name), this.getString(R.string.loading), contentIntent);//from ww w .ja va 2 s. c o m notification.flags = Notification.FLAG_AUTO_CANCEL; return notification; }
From source file:com.joulespersecond.seattlebusbot.tripservice.NotifierTask.java
@SuppressWarnings("deprecation") private void setLatestInfo(Notification notification, String stopId, String routeId, long timeDiff, PendingIntent deleteIntent) {//w w w.jav a 2s . c om final String title = mContext.getString(R.string.app_name); final PendingIntent intent = PendingIntent.getActivity(mContext, 0, new ArrivalsListActivity.Builder(mContext, stopId).getIntent(), PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(mContext, title, getNotifyText(routeId, timeDiff), intent); // #104 - Bug in setLatestEventInfo() erases the deleteIntent, so reset it here notification.deleteIntent = deleteIntent; }
From source file:com.csipsimple.service.SipNotifications.java
@SuppressWarnings("deprecation") private void searchNotificationPrimaryText(Context aContext) { try {/*from w w w .ja v a2s. c o m*/ Notification ntf = new Notification(); ntf.setLatestEventInfo(aContext, TO_SEARCH, "", null); LinearLayout group = new LinearLayout(aContext); ViewGroup event = (ViewGroup) ntf.contentView.apply(aContext, group); recurseSearchNotificationPrimaryText(event); group.removeAllViews(); } catch (Exception e) { Log.e(THIS_FILE, "Can't retrieve the color", e); } }