NotificationCompat.Builderを使用して簡単な通知を作成し、それを通知バーに追加しています。API 17を実行しているAVDでは、通知は期待どおりに通知プルダウンに表示されます。ただし、API 13を実行しているAVDでは、通知のタイトル/テキスト/情報が表示されません(おそらく、黒い背景に対して黒いテキストが原因です)。
私の問題の解決策を探していたところ、次のことがわかりました。カスタム通知の色とテキストの色しかし、これは通知にカスタムレイアウトを使用する場合にのみ当てはまるようです。
これが私のコードです:
private static int notificationId = 1;
private void displayNotification() {
// create an Intent to launch the Show Notification activity
// (when user selects the notification on the status bar)
Intent i = new Intent(this, ShowNotificationActivity.class);
// pass it some value
i.putExtra(ShowNotificationActivity.NOTIF_ID, notificationId);
// wrap it in a PendingIntent
PendingIntent pendingIntent = PendingIntent.getActivity(this, notificationId, i, 0);
// create the notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle("This is the Title #" + notificationId);
builder.setContentText("This is the Text");
builder.setContentInfo("This is the Info");
builder.setContentIntent(pendingIntent);
builder.setSmallIcon(android.R.drawable.ic_notification_overlay);
builder.setAutoCancel(true);
Notification notif = builder.build();
// display the notification
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
nm.notify(notificationId, notif);
notificationId++;
}
API17とAPI13で通知プルダウンを示すスクリーンショットを投稿したかったのですが、画像を投稿するのに十分な「レピュテーションポイント」がないようです。したがって、書面による説明で十分だと思います。
API 17では、通知プルダウンに通知のアイコン(赤い点)、タイトル、およびテキストが表示されます。背景色は黒、テキストの色は白です。
API 13では、アイコン(赤い点)のみが表示されます。背景色は黒ですが、テキストの色も黒かもしれません。
私は明らかな何かが欠けているのではないかと思いますが、私はこれに不慣れであり、どんな指針でもありがたいです。