java.lang.NoSuchMethodError: android.app.Notification $ Builder.addAction
Opracowałem aplikację dla systemu Android, w której podczas uruchamiania aplikacji wyświetlane było powiadomienie
Aplikacja działa idealnie, gdy uruchamiam kod na emulatorze Androida, gdzie, gdy próbuję uruchomić to samo na prawdziwym urządzeniu, które ma wersję 4.0.4 Androida
Wyrzuca mi błąd w logcat jako
05-13 19:06:45.824: E/AndroidRuntime(15402): FATAL EXCEPTION: main
05-13 19:06:45.824: E/AndroidRuntime(15402): java.lang.NoSuchMethodError: android.app.Notification$Builder.addAction
05-13 19:06:45.824: E/AndroidRuntime(15402): at com.example.gpstracker.MainActivity.onCreate(MainActivity.java:54)
05-13 19:06:45.824: E/AndroidRuntime(15402): at android.app.Activity.performCreate(Activity.java:4470)
05-13 19:06:45.824: E/AndroidRuntime(15402): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-13 19:06:45.824: E/AndroidRuntime(15402): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-13 19:06:45.824: E/AndroidRuntime(15402): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
Kod, który próbowałem, jest
Notification noti = new Notification.Builder(this)
.setContentTitle("Driver GPS Tracker Application")
.setContentText("9ciphers")
.setSmallIcon(R.drawable.ic_launcher).setContentIntent(in)
.addAction(R.drawable.ic_launcher, "Start", i)
.addAction(R.drawable.ic_launcher, "Stop", in)
.addAction(R.drawable.ic_launcher, "Exit", pIntent).build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Hide the notification after its selected
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
Toast.makeText(getApplicationContext(), "Application Started", Toast.LENGTH_SHORT).show();
notifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Czy ktoś może mi pomóc rozwiązać ten problem?
dzięki za pomoc