Android 自定义样式通知栏的坑RemoteServiceException

来源:互联网 发布:linux find type f 编辑:程序博客网 时间:2024/06/05 10:50
Android.app.RemoteServiceException: Bad notification posted from packagecom.my.package:

是的,就是这个异常。


没有使用系统提供的三个方法

setContentText()setContentTitle()setSmallIcon()

而用的是RemoteViews,然后就掉坑里了。

原因是这样的,请往下看~

  1. 布局中的控件只有7种,除此之外,均会报错!

    AnalogClock,Button,Chronometer,ImageButton,mageView,ProgressBar,TextView

  2. 另外还有一个问题,就是控件长宽的设定,必须为0dpwrap_content或者match_parent,除此之外,也均会报错!

if (layoutWidth != 0 && layoutWidth != ViewGroup.LayoutParams.MATCH_PARENT            && layoutWidth != ViewGroup.LayoutParams.WRAP_CONTENT) {        throw new IllegalArgumentException("Only supports 0, WRAP_CONTENT and MATCH_PARENT");    }

这就是原因,内部会检测。但不知为何,我接收到的都是文章开头提到的那个异常,让我好苦恼。

阅读全文
0 0
原创粉丝点击