错误通知:无法展开“状态栏通知”的远程视图。在安卓牛轧糖上
我用于显示通知。我在.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;
}
}
这在我的所有设备上都运行良好,但是:
我在Crashlytics上收到大量这个问题,仅在装有Android Nougat的设备上:
致命异常: android.app.RemoteServiceException: 从 package my.package 发布的错误通知: 无法展开 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)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
我试图更改图形资源,如通知图标,以清理项目,以便遵循此建议。
我注意到,当我稍后发布新版本的应用程序时,具有此问题的设备数量增加了一周,这些数字将减少到零。
此问题也已报告给 Google 和 OneSignal
SDK 的开发者。
我正在寻找任何解决方法,任何可以帮助消除此问题的想法或建议。