【遇见Android bug】java.lang.IllegalArgumentException: contentView required: pkg=com.sinvideo.joyshow id
2014-09-16 10:18
615 查看
09-11 15:54:28.800: E/AndroidRuntime(24863): FATAL EXCEPTION: main
09-11 15:54:28.800: E/AndroidRuntime(24863): Process: com.sinvideo.joyshow, PID: 24863
09-11 15:54:28.800: E/AndroidRuntime(24863): java.lang.IllegalArgumentException: contentView required: pkg=com.sinvideo.joyshow id=1000 notification=Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x4 flags=0x0
kind=[null])
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.os.Parcel.readException(Parcel.java:1472)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.os.Parcel.readException(Parcel.java:1422)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:320)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.app.NotificationManager.notify(NotificationManager.java:136)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.app.NotificationManager.notify(NotificationManager.java:109)
09-11 15:54:28.800: E/AndroidRuntime(24863): at com.sinvideo.joyshow.view.SplashActivity$3$1.run(SplashActivity.java:193)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.os.Handler.handleCallback(Handler.java:733)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.os.Handler.dispatchMessage(Handler.java:95)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.os.Looper.loop(Looper.java:136)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.app.ActivityThread.main(ActivityThread.java:5262)
09-11 15:54:28.800: E/AndroidRuntime(24863): at java.lang.reflect.Method.invokeNative(Native Method)
09-11 15:54:28.800: E/AndroidRuntime(24863): at java.lang.reflect.Method.invoke(Method.java:515)
09-11 15:54:28.800: E/AndroidRuntime(24863): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:851)
09-11 15:54:28.800: E/AndroidRuntime(24863): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:667)
09-11 15:54:28.800: E/AndroidRuntime(24863): at dalvik.system.NativeStart.main(Native Method)
这个我原本的代码,想要解决这个问题,只需要给notification添加一个事件setLatestEventInfo。
解决方案如下:
但是setLatestEventInfo方法是一个过时的方法,至于用什么方式替代还有待研究
09-11 15:54:28.800: E/AndroidRuntime(24863): Process: com.sinvideo.joyshow, PID: 24863
09-11 15:54:28.800: E/AndroidRuntime(24863): java.lang.IllegalArgumentException: contentView required: pkg=com.sinvideo.joyshow id=1000 notification=Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x4 flags=0x0
kind=[null])
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.os.Parcel.readException(Parcel.java:1472)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.os.Parcel.readException(Parcel.java:1422)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:320)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.app.NotificationManager.notify(NotificationManager.java:136)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.app.NotificationManager.notify(NotificationManager.java:109)
09-11 15:54:28.800: E/AndroidRuntime(24863): at com.sinvideo.joyshow.view.SplashActivity$3$1.run(SplashActivity.java:193)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.os.Handler.handleCallback(Handler.java:733)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.os.Handler.dispatchMessage(Handler.java:95)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.os.Looper.loop(Looper.java:136)
09-11 15:54:28.800: E/AndroidRuntime(24863): at android.app.ActivityThread.main(ActivityThread.java:5262)
09-11 15:54:28.800: E/AndroidRuntime(24863): at java.lang.reflect.Method.invokeNative(Native Method)
09-11 15:54:28.800: E/AndroidRuntime(24863): at java.lang.reflect.Method.invoke(Method.java:515)
09-11 15:54:28.800: E/AndroidRuntime(24863): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:851)
09-11 15:54:28.800: E/AndroidRuntime(24863): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:667)
09-11 15:54:28.800: E/AndroidRuntime(24863): at dalvik.system.NativeStart.main(Native Method)
这个我原本的代码,想要解决这个问题,只需要给notification添加一个事件setLatestEventInfo。
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notify = new Notification(); notify.icon = R.drawable.ic_launcher; notify.tickerText = "点击下载最新App"; notify.when = System.currentTimeMillis(); notify.defaults = Notification.DEFAULT_LIGHTS; notify.flags = Notification.FLAG_AUTO_CANCEL; nm.notify(notificationId, notify); instance.put("activeUpdateShouldShow", false);
解决方案如下:
Intent intent = new Intent(ctx, UpdateService.class); intent.putExtra("apkUrl", apkurl); PendingIntent pendIntent = PendingIntent.getService(ctx, 0, intent, 0);
notify.setLatestEventInfo(ctx, "AAAAA", "BBBBBBB", pendIntent);
但是setLatestEventInfo方法是一个过时的方法,至于用什么方式替代还有待研究
相关文章推荐
- 关于dialog引起的java.lang.IllegalArgumentException:View=com.android.internal.policy.impl.PhoneWindow$Deco
- java.lang.IllegalArgumentException: View=com.android.in...
- [BUG记录]java.lang.IllegalArgumentException: contentIntent required
- [Android] View.setTag(key,Object) (java.lang.IllegalArgumentException: The key must be an application-specific resource id.)
- java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView{4380
- java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView
- 关于dialog引起的java.lang.IllegalArgumentException:View=com.android.internal.policy.impl.Ph
- [Bug]java.lang.IllegalArgumentException: contentIntent required
- java.lang.IllegalArgumentException: No view found for id 0x7f090003 for fragment MainFg{40d57e28 #0
- Android Caused by: java.lang.IllegalArgumentException: column '_id' does not exist
- java.lang.IllegalArgumentException: id to load is required for loading解决方法
- java.lang.IllegalArgumentException: id to load is required for loading
- Android异常总结---E/AndroidRuntime(23439): Caused by: java.lang.IllegalArgumentException: column '_id' d
- Android Caused by: java.lang.IllegalArgumentException: column '_id' does not exist
- java.lang.IllegalArgumentException: contentIntent required
- java.lang.IllegalArgumentException: contentIntent required
- 错误:java.lang.illegalArgumentException:No view id found for fragment
- java.lang.IllegalArgumentException: id to load is required for loading
- Android Caused by: java.lang.IllegalArgumentException: column '_id' does not exist
- java.lang.IllegalArgumentException: id to load is required for loading