Я разрабатываю Actionable Notifications в Android.
void createActionableNotification() {
Intent intent = new Intent(this, MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);
// Build notification
// Actions are just fake
Notification noti = new NotificationCompat.Builder(this)
.setContentTitle("New mail from " + "[email protected]")
.setContentText("Subject").setSmallIcon(R.drawable.moneybag)
.setContentIntent(pIntent)
.addAction(R.drawable.moneybag, "Call", pIntent)
.addAction(R.drawable.moneybag, "More", pIntent)
.addAction(R.drawable.moneybag, "And more", pIntent).build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// hide the notification after its selected
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
}
Таким образом, он отображает действия, подобные этому. Пожалуйста, проверьте изображение ниже.
Приложение работает с целевым SDK, Compile SDK API — 24, Min SDK — 20. Я тестировал с Marshmallow Device. Но в эмуляторе работает нормально. Версия SDK эмулятора: 24