如何管理条件通知:
这是我的代码,始终不会在通知栏上合并通知,并始终启动 DetailNotificationActivity 。
int icon = R.drawable.icon_notification_comment;
notification = new Notification(icon, pengomentar+" mengomentari artikel \""+judul+"\" : "+ isi_komentar, when);
notificationIntent = new Intent(context, ContentCommentActivity.class);
Bundle b = new Bundle();
b.putString("judul", judul);
b.putString("komentar", komentar);
b.putString("sekilas_isi_detail", sekilas_isi);
b.putString("date", date);
b.putString("id_tulisan_detail", id_tulisan);
b.putString("gambar_tulisan_detail", gambar_tulisan_detail);
b.putString("status_gambar_detail", status_gambar);
b.putString("kategori_detail", kategori);
b.putString("main_kategori_detail", main_kategori);
b.putString("seo_detail", seo_detail);
b.putString("Notifikasi", "Y");
b.putString("username", username);
b.putString("avatar", avatar);
b.putString("kordinat_lokasi_detail",kordinat_lokasi);
notificationIntent.putExtras(b);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent = PendingIntent.getActivity(context, unique_ids, notificationIntent, 0);
notification.setLatestEventInfo(context, pengomentar+" mengomentari artikel \""+judul+"\"", isi_komentar, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
//notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3");
// Vibrate if vibrate is enabled
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.number += 1;
notificationManager.notify(unique_ids, notification);
如何让它发挥作用?
注意:从上面的api 8开始工作