Ändern der LED-Farbe für Benachrichtigungen

Ich bin im Grunde nur das Experimentieren mit Android-Entwicklung, und vor ein paar Tagen stieß ich auf diese app mit dem Namen "Go SMS Pro", der unter anderem auch das einrichten von Benachrichtigungen in verschiedenen Farben (blau, grün, orange, rosa und hellblau). So, ich habe versucht, dies zu tun, mich in meiner eigenen app, allerdings kann ich auch nicht ändern neiher die Farbe noch das blinken der internen LED. Derzeit nutze ich diesen code:

public class MainActivity extends Activity {
  static final int NOTIFICATION_ID = 1;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button button = (Button) findViewById(R.id.button);
    button.setOnClickListener(buttonOnClick);
  }

  public OnClickListener buttonOnClick = new OnClickListener() {

    @Override
    public void onClick(View v) {
      String ns = Context.NOTIFICATION_SERVICE;
      NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

      Notification notification = new Notification(R.drawable.icon, "Hello", System.currentTimeMillis());
      notification.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_AUTO_CANCEL;
      notification.ledARGB = Color.BLUE;
      notification.ledOnMS = 1000;
      notification.ledOffMS = 300;

      Context context = getApplicationContext();
      CharSequence contentTitle = "My notification";
      CharSequence contentText = "Hello World!";
      Intent notificationIntent = new Intent(MainActivity.this, MainActivity.class);
      PendingIntent contentIntent = PendingIntent.getActivity(MainActivity.this, 0, notificationIntent, 0);

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

      mNotificationManager.notify(NOTIFICATION_ID, notification);
    }
  };
}

Aber wie gesagt, es funktioniert nicht, wie ich es möchte, sondern es einfach nur blinkt regelmäßig grün mit der Standard-Verzögerung, und nicht die, die ich eingestellt habe in meinem code.

Kann jemand sehen, was falsch ist mit meinem code, oder weiß, wenn ich etwas anderes zu tun, um dies zu erreichen?

InformationsquelleAutor der Frage Frxstrem | 2011-05-29

Schreibe einen Kommentar