What is the proper way to add an action to the notification in API 23 since addAction(int icon, CharSequence title, PendingIntent intent) is deprec
You just have to use NotificationCompat.Builder builder in place of Notification.Builder builder because NotificationCompat.Builder allows you to build your application below Android Version 4.1
Solved by using NotificationCompat.builder:
String strTitle = getString(R.string.new_message);
String strText = getString(R.string.hi_whats_up);
Intent intent = new Intent(this, NotificationView.class);
intent.putExtra("title", strTitle);
intent.putExtra("text", strText);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setTicker("Notification Ticker")
.setContentTitle("Notification Title")
.setContentText("Notification Text")
.addAction(R.mipmap.ic_launcher, "Notification Action", pendingIntent)
.setContentIntent(pendingIntent)
.setAutoCancel(true);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());