在应用程序启动时,我已经开发了在那里我已经使用通知中显示的Android应用程序
该应用程序完美的作品,当我运行Android模拟器的代码中,当我尝试运行在具有的4.0.4版本的Android真实设备相同
这引发了我的错误在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);
任何人都可以在这里帮我理清了这一点,我会在这里失去了一些东西
谢谢你的帮助