gpt4 book ai didi

android.app.RemoteServiceException 已发布错误通知

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:10:50 32 4
gpt4 key购买 nike

有时我的应用程序会遇到这种异常:

Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package com.packagename: Couldn't expand RemoteViews for: StatusBarNotification(pkg=com.packagename user=UserHandle{0} id=136094146 tag=null score=0: Notification(pri=0 contentView=com.packagename/0x109007e vibrate=default sound=default defaults=0xffffffff flags=0x11 kind=[null]))
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(NativeStart.java)

代码创建通知:

PendingIntent intent = PendingIntent.getActivities(this, id,
notificationIntents, PendingIntent.FLAG_UPDATE_CURRENT);


int color = ContextCompat.getColor(this, R.color.notif_background);

NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setContentText(description)
.setSmallIcon(getSmallIcon())
.setLargeIcon(getLargeIcon())
.setColor(color)
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigPictureStyle().bigLargeIcon(largeIcon))
.setContentIntent(intent);

if (title != null) {
notificationBuilder.setContentTitle(title)
.setTicker(title)
.setStyle(new NotificationCompat.BigTextStyle()
.setBigContentTitle(title).bigText(description));
} else {
notificationBuilder.setStyle(new NotificationCompat.BigTextStyle()
.bigText(description));
}

if (image != null) {
notificationBuilder
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(image).setSummaryText(description));
}
android.app.Notification notification = notificationBuilder.build();
notificationManager.notify(id, notification);

关于stack overflow的解决方案我几乎都看过了,说明这个问题是关于自定义布局的。但是我没有使用自定义布局。我不明白确切的问题是什么。谁能帮忙?

最佳答案

我在 .webp 中使用通知图标时遇到了同样的问题对于 KitKat 及以下版本的设备,请确保使用 .png 中的图标。

关于android.app.RemoteServiceException 已发布错误通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40255271/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com