A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© linilq 初级黑马   /  2014-3-31 10:07  /  1033 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

显示自定义的notification时,报android.app.RemoteServiceException: Bad notification posted from package...

自定义的notification中都是常规控件,imagebutton imageview  textview  布局是linearlayout;所以排除
控件导致错误的可能;只是在设定notification的时候不知道还有些什么关键问题要考虑
请大家帮指导一下,不胜感激。。
关键代码如下:
  1.         private void showNotification() {
  2.                
  3.                 Intent intent =new Intent(this,MainActivity.class);
  4.                 intent.setAction(Intent.ACTION_MAIN);
  5.         intent.addCategory(Intent.CATEGORY_LAUNCHER);
  6.                 //设置图标、滚动文本、时间戳、点击跳转
  7.                 PendingIntent pIntent = PendingIntent.getActivity(this, 0,
  8.                                 intent,PendingIntent.FLAG_CANCEL_CURRENT);
  9.                 RemoteViews contentView = new RemoteViews(this.getPackageName(),
  10.                                                                         R.layout.extension);
  11.                
  12.                 Log.v(TAG, "RemoteView is ready");
  13.                
  14.                 Notification notification = new Notification.Builder(this)
  15.                                                                         .setOngoing(true)
  16.                                                                         .setSmallIcon(R.drawable.ic_launcher)
  17.                                                                         .setTicker("Enjoy your life!")
  18.                                                                         .setContent(contentView)
  19.                                                                         .setContentIntent(pIntent)
  20.                                                                         .build();
  21.                 Log.v(TAG, "notification is ready");
  22.                 //显示提示
  23.                 mNM.notify(NOTIFICATION,notification);
  24.                
  25.        
  26.         }
复制代码



评分

参与人数 1技术分 +1 收起 理由
菜小徐 + 1

查看全部评分

1 个回复

倒序浏览
自己先把目前对这个问题的了解说一下吧:
给notification设计自定义的remoteview时,是有高度限制的;楼主的问题发生在想要定义一个扩展的notification,但是直接将这个大的remoteview布局直接加入时导致无法完全显示,故而报bad notification;
但是更多的问题也随之而来,决定再开一个贴进行讨论,请各位多指教吧!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马