私は基本的に Android 開発の実験を行っているところですが、数日前に「Go SMS Pro」というアプリに出会いました。このアプリは、さまざまな色 (青、緑、オレンジ、ピンク、ライト) で通知を設定できます。青い)。だから、私は自分のアプリでこれを自分でやろうとしましたが、色やLEDの点滅内部を変更することはできません。私は現在このコードを使用しています:
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);
}
};
}
しかし、私が言ったように、それは私が望むようには機能しません。代わりに、コードで設定した遅延ではなく、デフォルトの遅延で通常の緑色で点滅するだけです。
私のコードの何が問題なのか、またはこれを達成するために何か他のことをしなければならないかどうかを知っている人はいますか?