发布Notification报错的问题
来源:互联网 发布:怎么看淘宝的图片大小 编辑:程序博客网 时间:2024/06/05 10:07
http://blog.csdn.net/carterjin/article/details/7520701
自己学习Notification的时候,写了一个练习,发布一个Notification。
但是在运行时候报了一个错误:
04-28 08:18:36.766: E/AndroidRuntime(683): FATAL EXCEPTION: main
04-28 08:18:36.766: E/AndroidRuntime(683): java.lang.IllegalArgumentException: contentView required: pkg=com.carter id=43notification=Notification(vibrate=default,sound=default,defaults=0xffffffff,flags=0x0)
04-28 08:18:36.766: E/AndroidRuntime(683): at android.os.Parcel.readException(Parcel.java:1326)
04-28 08:18:36.766: E/AndroidRuntime(683): at android.os.Parcel.readException(Parcel.java:1276)
04-28 08:18:36.766: E/AndroidRuntime(683): at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:274)
04-28 08:18:36.766: E/AndroidRuntime(683): at android.app.NotificationManager.notify(NotificationManager.java:111)
04-28 08:18:36.766: E/AndroidRuntime(683): at android.app.NotificationManager.notify(NotificationManager.java:91)
04-28 08:18:36.766: E/AndroidRuntime(683): at com.carter.NotificationTestActivity$1.onClick(NotificationTestActivity.java:45)
04-28 08:18:36.766: E/AndroidRuntime(683): at android.view.View.performClick(View.java:2485)
04-28 08:18:36.766: E/AndroidRuntime(683): at android.view.View$PerformClick.run(View.java:9080)
04-28 08:18:36.766: E/AndroidRuntime(683): at android.os.Handler.handleCallback(Handler.java:587)
04-28 08:18:36.766: E/AndroidRuntime(683): at android.os.Handler.dispatchMessage(Handler.java:92)
04-28 08:18:36.766: E/AndroidRuntime(683): at android.os.Looper.loop(Looper.java:123)
04-28 08:18:36.766: E/AndroidRuntime(683): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-28 08:18:36.766: E/AndroidRuntime(683): at java.lang.reflect.Method.invokeNative(Native Method)
04-28 08:18:36.766: E/AndroidRuntime(683): at java.lang.reflect.Method.invoke(Method.java:507)
04-28 08:18:36.766: E/AndroidRuntime(683): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-28 08:18:36.766: E/AndroidRuntime(683): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-28 08:18:36.766: E/AndroidRuntime(683): at dalvik.system.NativeStart.main(Native Method)
大致说的内容是,抛出了一个非法参数异常,原因是需要contentView
源代码是:
- Intent intent = new Intent(NotificationTestActivity.this, OtherActivity.class);
- PendingIntent pendIntent = PendingIntent.getActivity(NotificationTestActivity.this, 0, intent, 0);
- Notification notification = new Notification();
- notification.icon = R.drawable.ok;
- notification.when = System.currentTimeMillis();
- notification.tickerText = "接收到了一条通知";
- notification.defaults = Notification.DEFAULT_ALL;
- NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
- manager.notify(NOTIFICATION_ID, notification);
在notification各项属性之后,发送之前加上
- notification.setLatestEventInfo(NotificationTestActivity.this, "点击查看", "点击查看详细内容", pendIntent);
后,一切正常了。
- 发布Notification报错的问题
- 发布Notification报错的问题
- Unity发布IOS在Xcode7.3报错的问题
- xfire调用cfx发布的service报错问题
- Notification类的问题
- 关于Unity发布Webgl在chrome中打开报错的问题
- cxf linux 无法发布服务,报no binding的问题
- Notification 的 TransactionTooLargeException的问题
- IIS发布 WebService 浏览器访问报错http 500问题
- weblogic发布报错
- 关于xfire发布的报错的愿意un
- MessageBox()报错的问题
- R 报错的问题
- @override报错的问题
- 运行报错的问题:
- maven报错的问题
- UIwebview的报错问题
- 在用CXF发布服务端的时候报错
- 数据库设计原则
- (Linux 2.6设备管理机制)kobject和kset
- window 通过改变注册表键值设置ie代理(超级有用)
- 长方形
- sysfs文件系统
- 发布Notification报错的问题
- 树上的三角形
- SGU 108 滚动数组优化打表
- java的异常机制浅谈--更好的为他人服务
- POJ 2985 Treap平衡树(求第k大的元素)
- icon font在firefox下无法显示
- TimePicker的使用
- hadoop 负载均衡
- 在类中使用新线程对本类进行操作同样需要使用handler