public void sendNotification() {
    builder.setSmallIcon(R.drawable.ic_launcher);

    //        if(Constants.NOTIFICATION_CONDUCTOR==typeNototification){
    //            builder.setAutoCancel(false);
    //        }
    //
    //        else{
    //            builder.setAutoCancel(true);
    //
    //        }
    builder.setLargeIcon(
        BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher));

    if (contentTitle != null) builder.setContentTitle(contentTitle);
    if (contentText != null) builder.setContentText(contentText);
    if (subText != null) builder.setSubText(subText);

    NotificationManager notificationManager =
        (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID, builder.build());
  }
  @Override
  public void vaddStatNotif(final Context ctxt, final StatusMessage in) {
    StatusMessage m = validateStrings(in);

    if (m.getShow() != 1) {
      vcancel(ctxt, STAT_TAG, NotifUtil.STATNOTIFID);
      return;
    }

    if (NotifUtil.ssidStatus == NotifUtil.SSID_STATUS_UNMANAGED) {
      m.setStatus(
          new StringBuilder(ctxt.getString(R.string.unmanaged)).append(m.getStatus()).toString());
    }

    NotificationCompat.Builder statbuilder = new NotificationCompat.Builder(ctxt);
    Intent intent =
        new Intent(ctxt, WifiFixerActivity.class)
            .setAction(Intent.ACTION_MAIN)
            .setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    statbuilder.setContentIntent(PendingIntent.getActivity(ctxt, 0, intent, 0));
    statbuilder.setOnlyAlertOnce(true);
    statbuilder.setOngoing(true);
    statbuilder.setWhen(0);
    statbuilder.setPriority(NotificationCompat.PRIORITY_MIN);
    statbuilder.setSmallIcon(getIconfromSignal(m.getSignal(), ICON_SET_SMALL));
    statbuilder.setLargeIcon(
        BitmapFactory.decodeResource(
            ctxt.getResources(), getIconfromSignal(m.getSignal(), ICON_SET_LARGE)));
    statbuilder.setContentText(m.getStatus());
    statbuilder.setSubText(ctxt.getString(R.string.network_status));
    statbuilder.setContentTitle(m.getSSID());
    /*
     * Fire the notification
     */
    notify(ctxt, NotifUtil.STATNOTIFID, STAT_TAG, statbuilder.build());
  }
Beispiel #3
0
 @Override
 public Builder setSubText(CharSequence text) {
   super.setSubText(text);
   return this;
 }
  private void showNotification(
      int playState, int audioPath, String title, String artist, String album, Bitmap artwork) {

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setWhen(System.currentTimeMillis());
    builder.setContentTitle(title);

    if (artwork != null) {
      builder.setLargeIcon(artwork);
    }
    int icon = R.drawable.ic_launcher;
    if (audioPath == AUDIO_PATH_SPEAKER) {
      icon = R.drawable.ic_speaker;
    } else if (audioPath == AUDIO_PATH_A2DP) {
      icon = R.drawable.ic_a2dp;
    } else if (audioPath == AUDIO_PATH_WIRED) {
      icon = R.drawable.ic_wired;
    }
    builder.setSmallIcon(icon);

    builder.setTicker(title);
    builder.setPriority(NotificationCompat.PRIORITY_HIGH);
    builder.setContentText(artist);
    builder.setSubText(album);

    PendingIntent pendingIntent = null;
    Intent intent = new Intent(this, PlaybackService.class);
    String keyTop;
    String action;
    if (playState == PLAY_STATE_PAUSED) {
      action = ACTION_PAUSE;
      keyTop = "Pause";
      icon = android.R.drawable.ic_media_pause;

      intent = new Intent(this, PlaybackService.class);
      intent.setAction(ACTION_TRACK_DOWN);
      pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
      builder.addAction(android.R.drawable.ic_media_previous, "Prev", pendingIntent);

    } else {
      action = ACTION_PLAY;
      keyTop = "Play";
      icon = android.R.drawable.ic_media_play;

      intent = new Intent(this, PlaybackService.class);
      intent.setAction(ACTION_STOP);
      pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
      builder.addAction(android.R.drawable.ic_delete, "Stop", pendingIntent);
    }

    intent = new Intent(this, PlaybackService.class);
    intent.setAction(action);
    pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.addAction(icon, keyTop, pendingIntent);

    intent = new Intent(this, PlaybackService.class);
    intent.setAction(ACTION_TRACK_UP);
    pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.addAction(android.R.drawable.ic_media_next, "Next", pendingIntent);

    intent = new Intent(this, SimpleMusicPlayer.class);
    pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(pendingIntent);

    startForeground(R.id.notification_id, builder.build());
    // startForeground(R.id.notification_id, new
    // NotificationCompat.InboxStyle(builder).addLine("test1").addLine("test2").build());
  }