java.lang.NoSuchMethodError: android.app.Notification $ Builder.addAction
Я разработал приложение для Android, где я использовал уведомление, которое будет отображаться при запуске приложения
Приложение прекрасно работает, когда я запускаю код на эмуляторе Android, когда я пытаюсь запустить то же самое на реальном устройстве с версией Android 4.0.4.
Это выдает ошибку в logcat как
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)
Код, который я попробовал,
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);
может кто-нибудь здесь помочь мне разобраться, я что-то здесь упускаю
Спасибо за вашу помощь