Tôi có một số mã tạo ra một số thông báo, nó thực sự cơ bản.Android 4: không thể loại bỏ thông báo bằng cách vuốt
int icon = R.drawable.notification;
CharSequence tickerText = "Text";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = "Text";
CharSequence contentText = "Text";
Intent notificationIntent = new Intent(this, RequestActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.flags |= Notification.DEFAULT_SOUND;
notification.flags |= Notification.DEFAULT_VIBRATE;
notification.flags |= Notification.DEFAULT_LIGHTS;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(notificationID, notification);
Tất cả đều hoạt động tốt trong 2.1. Trong 4.0, tất cả đều hoạt động tốt ngoại trừ hành động vuốt-to-loại bỏ không hoạt động. Thông báo chuyển sang một bên, sau đó nhét và trả lại. Bất kỳ ý tưởng nào? Cảm ơn.
cố gắng để loại bỏ FLAG_AUTO_CANCEL –
@Copa đã cố gắng – James
mh ... cố gắng gán cờ đầu tiên ntofication.flags và không Bitwise hoặc lá cờ đầu tiên. Thay đổi notification.flags | = DEFAULT_SOUND thành notification.flags = Notification.DEFAULT_SOUND; Có lẽ điều này sẽ giúp –