安卓消息栏运行出现一个异常,麻烦帮看看

iphilip 2016-03-15 05:58:11
我是想在消息栏做个类似微信添加好友的添加请求,消息栏接到消息有个同意、拒绝按钮。在网上找了个例子比划着写了下,但是程序运行异常。
03-15 17:56:19.028: E/AndroidRuntime(20664): android.app.RemoteServiceException: Bad notification posted from package com.kaka: Couldn't expand RemoteViews for: StatusBarNotification(pkg=com.abc user=UserHandle{0} id=1 tag=null score=0: Notification(pri=0 contentView=com.kaka/0x7f03000d vibrate=null sound=null defaults=0x0 flags=0x4 kind=[null]))

网上查的说是没设置这,但是我设置了啊!nf.contentIntent = pi;
Log跟踪能打印出STEP1和STEP2.


nm = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Notification nf = new Notification( R.drawable.ic_launcher,"任务请求",System.currentTimeMillis());
nf.flags = Notification.FLAG_INSISTENT;
RemoteViews rv = new RemoteViews(this.getPackageName(),R.layout.notify_req);

Log.i( TAG, "STEP 1!" );

Intent intent = new Intent(this,PersonAtv.class);
PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);

nf.contentIntent = pi;
nf.contentView = rv;

nm.notify(1, nf);

Log.i( TAG, "STEP 2!" );
...全文
121 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
iphilip 2016-03-16
  • 打赏
  • 举报
回复
解决了,是RemoteView的布局文件那天写到半截有其他事情打断,有个按钮没设置高度。
iphilip 2016-03-16
  • 打赏
  • 举报
回复
去掉这句不抛异常了 //nm.notify(1, nf); 可是怎样让通知显示呢。

80,490

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧