Example usage for android.app Notification Notification

List of usage examples for android.app Notification Notification

Introduction

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

Prototype

@Deprecated
public Notification(int icon, CharSequence tickerText, long when) 

Source Link

Document

Constructs a Notification object with the information needed to have a status bar icon without the standard expanded view.

Usage

From source file:edu.mit.viral.shen.DroidFish.java

/** Set/clear the "heavy CPU usage" notification. */
private final void setNotification(boolean show) {
    if (notificationActive == show)
        return;//  w  w w.  j  a  va 2  s . c om
    notificationActive = show;
    final int cpuUsage = 1;
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
    if (show) {
        int icon = R.drawable.icon;
        CharSequence tickerText = getString(R.string.heavy_cpu_usage);
        long when = System.currentTimeMillis();
        Notification notification = new Notification(icon, tickerText, when);
        notification.flags |= Notification.FLAG_ONGOING_EVENT;

        Context context = getApplicationContext();
        CharSequence contentTitle = getString(R.string.background_processing);
        CharSequence contentText = getString(R.string.lot_cpu_power);
        Intent notificationIntent = new Intent(this, CPUWarning.class);

        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

        mNotificationManager.notify(cpuUsage, notification);
    } else {
        mNotificationManager.cancel(cpuUsage);
    }
}

From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java

private void showNotify(int paramInt, String paramString1, String paramString2, String paramString3) {
      if (!getConfig().getBoolean("hide_notify", false)) {
          long l = System.currentTimeMillis();
          FragmentActivity localFragmentActivity = getContext();
          Object localObject = new Intent(getContext(), patchActivity.class);
          localObject = PendingIntent.getActivity(getContext(), 0, (Intent) localObject, 0);
          NotificationManager localNotificationManager = (NotificationManager) getContext()
                  .getSystemService("notification");
          paramString2 = new Notification(2130837552, paramString2, l);
          new Notification();
          paramString2.setLatestEventInfo(localFragmentActivity, paramString1, paramString3,
                  (PendingIntent) localObject);
          localNotificationManager.notify(paramInt, paramString2);
      }// w ww .  ja  v  a  2 s. c o m
  }