Sie müssen nur Verwenden Sie den NotificationCompat.Builder-Builder anstelle des Notification.Builder-Builders, da Nein tificationCompat.Builder können Sie Ihre Anwendung unter Android Version 4.1
Gelöst von NotificationCompat.builder mit bauen:
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());
Nach den [docs] (http://developer.android.com/reference/android /app/Notification.Builder.html#addAction%28android.app.Notification.Action%29), sollten Sie 'addAction (Notification.Action action)' stattdessen verwenden. – Tigger
http://StackOverflow.com/Questions/16852270/How-to-Implement-the-deprecated-methods-of-notification – sasikumar
Ich sah schon das Beispiel @sasikumar, es hilft mir nicht, ich verstehe nicht Wie ich die 'Notification.Action'-Aktion erstellen kann –