gpt4 book ai didi

java - Android Nougat 上的错误通知 : Couldn't expand RemoteViews for: StatusBarNotification.

转载 作者:搜寻专家 更新时间:2023-10-30 19:44:58 27 4
gpt4 key购买 nike

我使用 OneSignal SDK 来显示通知。我在 OneSignalPushService.java 中执行此操作。

OneSignalPushService.java:

public class OneSignalPushService extends NotificationExtenderService {

@Override
protected boolean onNotificationProcessing(OSNotificationReceivedResult notification) {

if (!TinyDbWrap.getInstance().isPushEnabled()) {
KLog.d(this.getClass().getSimpleName(), "Notification will not displayed");
return true;
}

OverrideSettings overrideSettings = new OverrideSettings();
overrideSettings.extender = new NotificationCompat.Extender() {
@Override
public NotificationCompat.Builder extend(NotificationCompat.Builder notificationBuilder) {
notificationBuilder.setDefaults(0);
notificationBuilder.setContentTitle(getApplicationContext().getResources().getString(R.string.app_name));

boolean is_in_silent_mode = false; /*or true by user's settings in app*/
/*TinyDbWrap.getInstance()... - it stores user's settings*/
KLog.d(OneSignalPushService.class.getSimpleName(), "Notification isSoundPushEnabled: " + TinyDbWrap.getInstance().isSoundPushEnabled());
if (!is_in_silent_mode && TinyDbWrap.getInstance().isSoundPushEnabled()) {
notificationBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
} else {
notificationBuilder.setSound(null);
}

KLog.d(OneSignalPushService.class.getSimpleName(), "Notification isVibrationPushEnabled: " + TinyDbWrap.getInstance().isVibrationPushEnabled());
if (!is_in_silent_mode && TinyDbWrap.getInstance().isVibrationPushEnabled()) {
notificationBuilder.setVibrate(new long[]{0, 100, 200, 300, 400});
} else {
notificationBuilder.setVibrate(new long[]{0});
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
notificationBuilder.setColor(ContextCompat.getColor(getApplicationContext(), R.color.bg_first_item_white_scheme));
}
notificationBuilder.setLights(ContextCompat.getColor(getApplicationContext(), R.color.time_white_sheme), 500, 500);
return notificationBuilder;
}
};

OSNotificationDisplayedResult result = displayNotification(overrideSettings);
if (result != null) {
KLog.d(OneSignalPushService.class.getSimpleName(), "Notification displayed with id: " + result.androidNotificationId);
}

return true;
}

}

这适用于我所有的设备,但是:

我仅在装有 Android Nougat 的设备上收到有关 Crashlytics 的大量此类问题:

Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package my.package: Couldn't expand RemoteViews for: StatusBarNotification(pkg=my.package user=UserHandle{0} id=-1542711428 tag=null key=0|my.package|-1542711428|null|10184: Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x19 color=0xff56a0d3 vis=PUBLIC semFlags=0x0 semPriority=0)) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1813) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6776) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)

不幸的是,我无法在装有 Android Nougat 的设备上重现此问题,以了解如何消除它。

我试图更改通知图标等图形资源,以清理项目以遵循this advice .

当我发布新版本的应用程序后,我注意到有这个问题的设备数量增加了一周,这些数字减少到零。

这个问题还有reported to Googledevelopers of OneSignal SDK .

我正在寻找可以帮助消除此问题的任何解决方法、任何想法或建议。

最佳答案

我认为发生此崩溃是因为您的通知包含对 PendingIntent 包中图标的整数引用,并且该整数稍后在发布到 NotificationManager 时被引用。

在获取整数引用和挂起 Intent 之间,更新了应用程序并且更改了所有可绘制对象引用。用于引用正确可绘制对象的整数现在引用了不正确的可绘制对象或根本没有(根本没有 - 导致此崩溃)

这是由

证明的

I noticed that number of devices with this issue increase for a week when I release a new version of the app later these numbers decrease to zero.

作为一种解决方案,您可以在更新应用程序后重建所有通知。

关于java - Android Nougat 上的错误通知 : Couldn't expand RemoteViews for: StatusBarNotification.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46873429/

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