Đây là mã của tôi để thiết lập thông báo bằng các nút.Các nút Thông báo của Android không hiển thị
Intent receiverIntent = new Intent(ctx, ResponsivePrefsActivity.class);
PendingIntent pReceiverIntent = PendingIntent.getActivity(ctx, 1, receiverIntent, 0);
Intent clearIntent = new Intent(ctx, ResponsivePrefsActivity.class);
clearIntent.setAction("clear");
PendingIntent pClearIntent = PendingIntent.getActivity(ctx, 1, clearIntent, 0);
Intent colorsIntent = new Intent(ctx, ResponsivePrefsActivity.class);
colorsIntent.setAction("colors");
PendingIntent pColorsIntent = PendingIntent.getActivity(ctx, 1, colorsIntent, 0);
Intent animationIntent = new Intent(ctx, ResponsivePrefsActivity.class);
animationIntent.setAction("animation");
PendingIntent pAnimation = PendingIntent.getActivity(ctx, 1, animationIntent, 0);
Notification.Builder builder;
builder = new Notification.Builder(ctx).setSmallIcon(R.drawable.ic_launcher).setAutoCancel(false)
.setContentTitle("Draw Me: A Live Wallpaper").setContentText("Never get bored again!")
.setContentIntent(pReceiverIntent).addAction(R.raw.ic_menu_close_clear_cancel, "Clear", pClearIntent)
.addAction(R.raw.ic_menu_edit, "Colors", pColorsIntent).addAction(R.raw.ic_menu_play_clip, "Animation", pAnimation);
Notification notification = builder.build();
NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notification);
Thông báo hiển thị nhưng các nút thì không. Thiết bị của tôi có Android 4.1.1 Tôi thiết lập thông báo này trong Phân đoạn. Tôi đang làm gì sai? Cảm ơn!
Câu trả lời của năm ....Tôi đổ lỗi cho bản cập nhật hệ điều hành mới nhất mà tôi đã thực hiện (4.2.2) nhưng không phải là lỗi trực tiếp của nó .... –
Câu trả lời này xứng đáng nhận được nhiều ưu điểm hơn !! – Swayam
câu trả lời hay. Tôi cũng đã giải quyết vấn đề này bằng cách sử dụng câu trả lời @Captain Blammo bằng cách gọi .setPriority (Notification.PRIORITY_MAX) trên trình xây dựng noticiation của tôi. Bằng cách này bạn vẫn có thể thấy các nút ngay cả khi bạn kết nối qua USB – Jake