public void update(int dockLevel, boolean charging) {
    int icon =
        charging
            ? R.drawable
                .stat_sys_battery_charge // local copy of android.R.drawable.stat_sys_battery_charge
            : R.drawable.stat_sys_battery; // local copy of android.R.drawable.stat_sys_battery

    // Notification Builder straight up refuses to create a notification without a ticker :(
    /*Notification notification = new Notification.Builder(mContext)
    .setSmallIcon(icon, dockLevel)
    .setContentTitle(title)
    .setContentText("Dock battery level: " + dockLevel + "%")
    //.setNumber(dockLevel)
    .setAutoCancel(false)
    .setOngoing(true)
    .setOnlyAlertOnce(true)
    .setTicker(null)
    .getNotification();*/

    Notification notification = new Notification(icon, null, System.currentTimeMillis());
    notification.iconLevel = dockLevel;
    notification.flags =
        Notification.FLAG_ONGOING_EVENT
            | Notification.FLAG_ONLY_ALERT_ONCE
            | Notification.FLAG_NO_CLEAR;
    notification.setLatestEventInfo(
        mContext, title, "Dock battery level: " + dockLevel + "%", null);

    notification.tickerText = null;
    notification.contentView.setInt(android.R.id.icon, "setImageLevel", dockLevel);
    mNotificationManager.notify(NOTIFICATION_DOCK, notification);
  }
  @TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "writeToParcel",
        args = {android.os.Parcel.class, int.class}),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "Notification",
        args = {android.os.Parcel.class})
  })
  public void testWriteToParcel() {
    mNotification = new Notification();
    mNotification.icon = 0;
    mNotification.number = 1;
    final Intent intent = new Intent();
    final PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
    mNotification.contentIntent = pendingIntent;
    final Intent deleteIntent = new Intent();
    final PendingIntent delPendingIntent = PendingIntent.getBroadcast(mContext, 0, deleteIntent, 0);
    mNotification.deleteIntent = delPendingIntent;
    mNotification.tickerText = TICKER_TEXT;

    final RemoteViews contentView =
        new RemoteViews(
            mContext.getPackageName(),
            com.android.internal.R.layout.status_bar_latest_event_content);
    mNotification.contentView = contentView;
    mNotification.defaults = 0;
    mNotification.flags = 0;
    final Uri uri = Uri.parse(URI_STRING);
    mNotification.sound = uri;
    mNotification.audioStreamType = 0;
    final long[] longArray = {1l, 2l, 3l};
    mNotification.vibrate = longArray;
    mNotification.ledARGB = 0;
    mNotification.ledOnMS = 0;
    mNotification.ledOffMS = 0;
    mNotification.iconLevel = 0;
    Parcel parcel = Parcel.obtain();
    mNotification.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    // Test Notification(Parcel)
    Notification result = new Notification(parcel);
    assertEquals(mNotification.icon, result.icon);
    assertEquals(mNotification.when, result.when);
    assertEquals(mNotification.number, result.number);
    assertNotNull(result.contentIntent);
    assertNotNull(result.deleteIntent);
    assertEquals(mNotification.tickerText, result.tickerText);
    assertNotNull(result.contentView);
    assertEquals(mNotification.defaults, result.defaults);
    assertEquals(mNotification.flags, result.flags);
    assertNotNull(result.sound);
    assertEquals(mNotification.audioStreamType, result.audioStreamType);
    assertEquals(mNotification.vibrate[0], result.vibrate[0]);
    assertEquals(mNotification.vibrate[1], result.vibrate[1]);
    assertEquals(mNotification.vibrate[2], result.vibrate[2]);
    assertEquals(mNotification.ledARGB, result.ledARGB);
    assertEquals(mNotification.ledOnMS, result.ledOnMS);
    assertEquals(mNotification.ledOffMS, result.ledOffMS);
    assertEquals(mNotification.iconLevel, result.iconLevel);

    mNotification.contentIntent = null;
    parcel = Parcel.obtain();
    mNotification.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    result = new Notification(parcel);
    assertNull(result.contentIntent);

    mNotification.deleteIntent = null;
    parcel = Parcel.obtain();
    mNotification.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    result = new Notification(parcel);
    assertNull(result.deleteIntent);

    mNotification.tickerText = null;
    parcel = Parcel.obtain();
    mNotification.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    result = new Notification(parcel);
    assertNull(result.tickerText);

    mNotification.contentView = null;
    parcel = Parcel.obtain();
    mNotification.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    result = new Notification(parcel);
    assertNull(result.contentView);

    mNotification.sound = null;
    parcel = Parcel.obtain();
    mNotification.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    result = new Notification(parcel);
    assertNull(result.sound);
  }
 public mNotification setSmallIcon(int i, int j)
 {
     mNotification.icon = i;
     mNotification.iconLevel = j;
     return this;
 }
 /**
  * A variant of {@link #setSmallIcon(int) setSmallIcon(int)} that takes an additional level
  * parameter for when the icon is a {@link android.graphics.drawable.LevelListDrawable
  * LevelListDrawable}.
  *
  * @param icon A resource ID in the application's package of the drawble to use.
  * @param level The level to use for the icon.
  * @see android.graphics.drawable.LevelListDrawable
  */
 public Builder setSmallIcon(int icon, int level) {
   mNotification.icon = icon;
   mNotification.iconLevel = level;
   return this;
 }