Example usage for android.app Notification setLatestEventInfo

List of usage examples for android.app Notification setLatestEventInfo

Introduction

In this page you can find the example usage for android.app Notification setLatestEventInfo.

Prototype

@Deprecated
public void setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText,
        PendingIntent contentIntent) 

Source Link

Document

Sets the #contentView field to be a view with the standard "Latest Event" layout.

Usage

From source file:com.dafeng.upgradeapp.util.AutoUpdateApk.java

protected void raise_notification() {
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager nm = (NotificationManager) context.getSystemService(ns);

    String update_file = preferences.getString(UPDATE_FILE, "");
    if (update_file.length() > 0) {
        setChanged();/*from   w  w  w .  j  av  a  2 s  .  c  o m*/
        notifyObservers(AUTOUPDATE_HAVE_UPDATE);

        // raise notification
        Notification notification = new Notification(appIcon, appName + " update", System.currentTimeMillis());
        notification.flags |= NOTIFICATION_FLAGS;

        CharSequence contentTitle = appName + " update available";
        CharSequence contentText = "Select to install";
        Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
        notificationIntent.setDataAndType(
                Uri.parse("file://" + context.getFilesDir().getAbsolutePath() + "/" + update_file),
                ANDROID_PACKAGE);
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
        nm.notify(NOTIFICATION_ID, notification);
    } else {
        nm.cancel(NOTIFICATION_ID);
    }
}

From source file:com.webkey.Ipc.java

public void notiyShow(Context pContext, String message) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(pContext);
    if (!prefs.getBoolean("statusbar", true)) {
        notiyDestroy(pContext);//from w w w . jav  a 2s .  c  om
        return;
    }
    Notification notification;

    //      Log.d("Webkey","START_notify");      
    if (manager == null)
        manager = (NotificationManager) pContext.getSystemService(Context.NOTIFICATION_SERVICE);

    notification = new Notification();
    notification.flags |= Notification.FLAG_ONGOING_EVENT;
    notification.icon = R.drawable.icon;
    //notification.tickerText = "Service is running";      
    notification.when = System.currentTimeMillis();
    //Intent notificationIntent = new Intent();
    //PendingIntent contentIntent = PendingIntent.getActivity(pContext, 0, notificationIntent, 0);
    //notification.setLatestEventInfo(pContext, "Webkey", "NotificationContent", contentIntent);
    Intent notifyIntent = new Intent(pContext, Webkey.class);
    notification.setLatestEventInfo(pContext, "Webkey", message,
            PendingIntent.getActivity(pContext, 0, notifyIntent, 0));
    manager.notify(1, notification);
}

From source file:io.coldstart.android.GCMIntentService.java

private void SendCombinedNotification(String EventCount) {
    Notification notification = new Notification(R.drawable.ic_stat_alert, EventCount + " new SNMP Traps!",
            System.currentTimeMillis());
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.defaults |= Notification.DEFAULT_VIBRATE;
    notification.flags |= Notification.FLAG_SHOW_LIGHTS;

    notification.ledARGB = 0xffff0000;/*w  ww .j a  v a 2s  .co  m*/

    notification.ledOnMS = 300;
    notification.ledOffMS = 1000;

    notification.defaults |= Notification.DEFAULT_SOUND;

    Context context = getApplicationContext();
    Intent notificationIntent = new Intent(this, TrapListActivity.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    notificationIntent.putExtra("forceRefresh", true);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    notification.setLatestEventInfo(context, EventCount + " SNMP Traps", "Click to launch ColdStart.io",
            contentIntent);
    mNM.notify(43523, notification);//NotificationID++ 
}

From source file:com.androidquery.simplefeed.activity.PostActivity.java

private void notify(String ticker, String title, String message, Intent intent) {

    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

    int icon = R.drawable.launcher;
    long when = System.currentTimeMillis();

    Notification notification = new Notification(icon, ticker, when);

    Context context = getApplicationContext();
    CharSequence contentText = message;

    int id = getNotifyId();
    PendingIntent contentIntent = PendingIntent.getActivity(this, id, intent, 0);

    notification.setLatestEventInfo(context, title, contentText, contentIntent);

    mNotificationManager.cancelAll();/*from w w w  . jav a  2s .  c o m*/

    AQUtility.debug("notify id", id);
    mNotificationManager.notify(id, notification);

}

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. java  2 s  . c o  m*/
    //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.autoupdateapk.AutoUpdateApk.java

protected void raise_notification() {
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager nm = (NotificationManager) context.getSystemService(ns);

    // nm.cancel( NOTIFICATION_ID ); // tried this, but it just doesn't do
    // the trick =(
    nm.cancelAll();//from   w w w  . j  av  a  2  s. c o  m

    String update_file = preferences.getString(UPDATE_FILE, "");
    if (update_file.length() > 0) {
        setChanged();
        notifyObservers(AUTOUPDATE_HAVE_UPDATE);

        // raise notification
        Notification notification = new Notification(appIcon, appName + " update", System.currentTimeMillis());
        notification.flags |= NOTIFICATION_FLAGS;

        CharSequence contentTitle = appName + " update available";
        CharSequence contentText = "Select to install";
        Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
        notificationIntent.setDataAndType(
                Uri.parse("file://" + context.getFilesDir().getAbsolutePath() + "/" + update_file),
                ANDROID_PACKAGE);
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
        nm.notify(NOTIFICATION_ID, notification);
    } else {
        nm.cancel(NOTIFICATION_ID);
    }
}

From source file:jp.co.conit.sss.sp.ex1.billing.BillingService.java

/**
 * ????//from ww w . j  av a  2  s. c  om
 * 
 * @param purchases
 */
private void notificationVerifiedProduct(List<VerifiedProduct> purchases) {

    Context context = getApplicationContext();
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    HashMap<String, VerifiedProduct> orderMap = new HashMap<String, VerifiedProduct>();
    int size = purchases.size() - 1;

    // ????Map???????????
    for (int i = size; i >= 0; i--) {
        VerifiedProduct vp = purchases.get(i);
        if (vp.getPurchaseState() == PurchaseState.PURCHASED) {
            orderMap.put(vp.getProductId(), vp);
        }
    }

    // ?????Notification??
    // ?????
    if (orderMap.size() > 0) {

        Notification notification = new Notification();
        notification.icon = R.drawable.ic_status;
        notification.tickerText = context.getString(R.string.notification_buy_result);
        notification.flags = Notification.FLAG_AUTO_CANCEL;

        Intent intent = new Intent();
        PendingIntent pendingintent = PendingIntent.getActivity(context, 0, intent, 0);

        String title = context.getString(R.string.notification_book);

        notification.setLatestEventInfo(context, context.getString(R.string.notification_buy_finish, title),
                context.getString(R.string.notification_urge_download), pendingintent);

        notificationManager.notify(0, notification);
    }

}

From source file:com.ubuntuone.android.files.service.UpDownService.java

private synchronized void showFailedTransfersNotification(int failed) {
    String title = "Ubuntu One";
    Resources r = getResources();
    String text = r.getQuantityString(R.plurals.failed_to_upload_n_files, failed, failed);

    final Intent intent = new Intent(UpDownService.this, PreferencesActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra(PreferencesActivity.SHOW_RETRY_FAILED, 1);
    final PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), REQUEST_RETRY_SCREEN, intent,
            0);/*from ww w . j  a  v  a 2s .  co  m*/

    Notification notification = new NotificationCompat.Builder(this).setOngoing(false).setTicker(title)
            .setSmallIcon(R.drawable.stat_u1_logo).setOnlyAlertOnce(true).setAutoCancel(true).getNotification();
    notification.setLatestEventInfo(this, title, text, pi);

    notificationManager.notify(R.id.stat_failed_upload_id, notification);
}

From source file:com.safecell.HomeScreenActivity.java

public void showNotification(String msg) {
    if (!new ConfigurePreferences(contextHomeScreenActivity).getTripStrated()) {
        Notification notification = new Notification(R.drawable.launch_icon, "Notify",
                System.currentTimeMillis());
        notification.setLatestEventInfo(HomeScreenActivity.this, "SafeCell", msg, PendingIntent.getActivity(
                HomeScreenActivity.this.getBaseContext(), 0, null, PendingIntent.FLAG_CANCEL_CURRENT));
        mManager.notify(APP_ID, notification);
    }/*ww w .j av  a2  s . c  om*/

}

From source file:com.bonsai.btcreceive.WalletService.java

private void showStatusNotification() {
    // In this sample, we'll use the same text for the ticker and
    // the expanded notification
    CharSequence started_txt = getText(R.string.wallet_service_started);
    CharSequence info_txt = getText(R.string.wallet_service_info);

    Notification note = new Notification(R.drawable.ic_stat_notify, started_txt, System.currentTimeMillis());

    Intent intent = new Intent(this, MainActivity.class);

    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);

    // Set the info for the views that show in the notification panel.
    note.setLatestEventInfo(this, getText(R.string.wallet_service_label), info_txt, contentIntent);

    note.flags |= Notification.FLAG_NO_CLEAR;

    startForeground(NOTIFICATION, note);
}