Notificação incorreta: não foi possível expandir as RemoteViews para: StatusBarNotification. no Android Nougat
eu usoOneSignal SDK
para mostrar notificações. Eu faço isso emOneSignalPushService.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;
}
}
Isso funciona bem em todos os meus dispositivos, mas:
Estou recebendo um grande número desse problema no Crashlytics apenas em dispositivos com Android Nougat:
Exceção fatal: android.app.RemoteServiceException: Notificação incorreta publicada no pacote my.package: Não foi possível expandir as RemoteViews para: StatusBarNotification (pkg = my.package user = UserHandle {0} id = -1542711428 tag = null key = 0 | my .package | -1542711428 | null | 10184: Notificação (pri = 0 contentView = vibração nula = som nulo = padrões nulos = 0x0 flags = 0x19 color = 0xff56a0d3 vis = PUBLIC semFlags = 0x0 semPriority = 0)) em android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1813) em android.os.Handler.dispatchMessage (Handler.java:102) em android.os.Looper.loop (Looper.java:154) em android.app.ActivityThread.main ( ActivityThread.java:6776) em java.lang.reflect.Method.invoke (Method.java) em com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:1496) em com.android.internal.os .ZygoteInit.main (ZygoteInit.java:1386)
Infelizmente, não consigo reproduzir esse problema nos meus dispositivos comAndroid Nougat
para entender como eu posso eliminá-lo.
Tentei alterar recursos gráficos, como ícones de notificação, para limpar o projeto, a fim de seguireste conselho.
Percebi que o número de dispositivos com esse problema aumenta por uma semana quando lancamos uma nova versão do aplicativo posteriormente, e esses números diminuem para zero.
Esta questão tambémdenunciado ao Google edesenvolvedores deOneSignal
SDK.
Estou procurando por soluções alternativas, idéias ou sugestões que possam ajudar a eliminar esse problema.