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

首先看报错信息:

E/AndroidRuntime(12220): FATAL EXCEPTION: mainE/AndroidRuntime(12220): Process: gn.com.android.update, PID: 12220E/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 自定义通知栏遇到的问题

相关文章:

你感兴趣的文章:

标签云: