在使用RemoteView创建自定义通知视图的时候一启动通知栏应用就停止运行。
查看错误提示,开始时为
StatusBar: Caused by: android.content.res.Resources$NotFoundException: File res/drawable/fm_statusbar_clear.xml from drawable resource ID #0x7f02003f
找不到资源,调整了使用方法后又出现了
04-11 18:54:27.542 21850 21850 E AndroidRuntime: android.app.RemoteServiceException: Bad notification posted from package com.xxx.yyy: Couldn't create icon: StatusBarIcon(pkg=com.xxx.yyyuser=0 id=0x7f020059 level=0 visible=true num=0 )
04-11 18:54:27.542 21850 21850 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
04-11 18:54:27.542 21850 21850 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
04-11 18:54:27.542 21850 21850 E AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
04-11 18:54:27.542 21850 21850 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5258)
04-11 18:54:27.542 21850 21850 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
04-11 18:54:27.542 21850 21850 E AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
04-11 18:54:27.542 21850 21850 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
04-11 18:54:27.542 21850 21850 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:702)
原因是缺少这个分辨率的Drawable资源。之前适配的时候只适配了1080分辨率的,而新的机型是720分辨率的。因此造成了上述错误。