android 自定义通知栏遇到的问题


首先看报错信息:

E/AndroidRuntime(12220): FATAL EXCEPTION: main

E/AndroidRuntime(12220): Process: gn.com.android.update, PID: 12220

E/AndroidRuntime(12220): android.app.RemoteServiceException: Bad notification posted from package gn.com.android.update: Couldn't expand RemoteViews for: StatusBarNotification(pkg=gn.com.android.update user=UserHandle{0} id=1 tag=null score=0 key=0|gn.com.android.update|1|null|10038: Notification(pri=0 contentView=gn.com.android.update/0x7f03000a vibrate=null sound=null defaults=0x0 flags=0x20 color=0x00000000 vis=PRIVATE))


E/AndroidRuntime(12220): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580)

E/AndroidRuntime(12220): at android.os.Handler.dispatchMessage(Handler.java:106)


E/AndroidRuntime(12220): at android.os.Looper.loop(Looper.java:189)


E/AndroidRuntime(12220): at android.app.ActivityThread.main(ActivityThread.java:5532)


E/AndroidRuntime(12220): at java.lang.reflect.Method.invoke(Native Method)


E/AndroidRuntime(12220): at java.lang.reflect.Method.invoke(Method.java:372)


E/AndroidRuntime(12220): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)


E/AndroidRuntime(12220): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)



代码如下:  

           通知栏定义布局中的一个控件这样写的:

            <ImageView
        android:id="@+id/notificationImage"
        android:layout_width="@android:dimen/notification_large_icon_width"
        android:layout_height="@android:dimen/notification_large_icon_height"
        android:scaleType="center"
        android:clickable="true"
        android:background="@*android:drawable/notify_panel_notification_icon_bg_tile"
        android:src="@drawable/stat_sys_download_anim0" 
        />

                  

         java中代码这样:

        if (null == mNotification) {
            mContentIntent = PendingIntent.getActivity(this, 0, new Intent(this, SettingUpdate.class), 0);
            // new一个通知对象
            mNotification = new Notification(R.drawable.stat_sys_download_anim0,
                    getString(R.string.notify_auto_update_title), System.currentTimeMillis());
            mNotification.flags = Notification.FLAG_NO_CLEAR;
        }
        mNotification.icon = R.drawable.stat_sys_download_anim0;


       解决方法:

            把 android:src="@drawable/stat_sys_download_anim0" 这句话删除掉,就没有该问题了,就不报错,但是显示为黑色。初步估计是systemui问题, 现在不知道原因,请大神看到回复下,谢谢


          后续编辑:

                  后面发现 android:background="@*android:drawable/notify_panel_notification_icon_bg_tile" 行代码出问题,原因是androidL系统中没有这个资源,kk上是编译通过的,android L上编译就出现那问题。。。。 修改就可以了,,,万里寻他千百度啊。。。。不容易啊。。。



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值