2014-12-10 5 views
10

Ho ottenuto molte eccezioni con il seguente stacktrace. Per Android < 5.0 funziona correttamente.Android 5 Notifica errata pubblicata dal pacchetto

Ottengo gli errori dalla mia app di notifica LED LED Blinker. https://play.google.com/store/apps/details?id=com.ledblinker Inserisco una notifica senza un'icona. Non so come riprodurlo, ma ho un sacco di rapporti sugli arresti anomali.

Qualche suggerimento?

ANDROID_VERSION=5.0 
PHONE_MODEL=Nexus 5 
BUILD=BOARD=hammerhead 
BOOTLOADER=HHZ12d 
BRAND=google 
CPU_ABI=armeabi-v7a 
CPU_ABI2=armeabi 
DEVICE=hammerhead 
DISPLAY=LRX21O 
FINGERPRINT=google/hammerhead/hammerhead:5.0/LRX21O/1570415:user/release-keys 
HARDWARE=hammerhead 
ID=LRX21O 
MANUFACTURER=LGE 
MODEL=Nexus 5 
PRODUCT=hammerhead 
RADIO=unknown 
SUPPORTED_32_BIT_ABIS=[Ljava.lang.String;@2b1c12b 
SUPPORTED_64_BIT_ABIS=[Ljava.lang.String;@20cc8988 
SUPPORTED_ABIS=[Ljava.lang.String;@302e2f21 
TAGS=release-keys 
TYPE=user 
UNKNOWN=unknown 
USER=android-build 
IS_DEBUGGABLE=false 
TIME=1415320210000 
VERSION.ACTIVE_CODENAMES=[Ljava.lang.String;@2a8c4f46 
VERSION.CODENAME=REL 
VERSION.INCREMENTAL=1570415 
VERSION.RELEASE=5.0 
VERSION.SDK=21 
VERSION.RESOURCES_SDK_INT=21 
VERSION.SDK_INT=21 

USER_APP_START_DATE=2014-12-08T05:50:24.000+01:00 
USER_CRASH_DATE=2014-12-08T07:32:05.000+01:00 
CUSTOM_DATA= 
STACK_TRACE=android.app.RemoteServiceException: Bad notification posted from package com.ledblinker: Couldn't create icon: StatusBarIcon(pkg=com.ledblinkeruser=0 id=0x0 level=0 visible=true num=0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1441) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5221) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 

Tutto funziona, ma a volte questo errore si verifica.

Ecco il codice che sta causando:

Notification resetNoti = new Notification(); 
resetNoti.ledARGB = Color.RED; 
resetNoti.ledOffMS = 0; 
resetNoti.ledOnMS = 1; 
resetNoti.flags = Notification.FLAG_SHOW_LIGHTS; 
+0

Nessun suggerimento che cosa posso fare? – MOST2K2

+1

Questo è successo anche a me, ieri, per la prima volta in assoluto. Su un Nexus 5 con Android 5.0. Strano! Ma non dalla tua app, che non è installata. Leggendo la discarica, non riesco a capire a quale app si riferisce. – emrys57

+0

Sì, penso che sia ancora una volta un bug del firmware. Uso questo codice da 2 anni e non è mai successo dal 5.0. – MOST2K2

risposta

0

provare con Classe NotificationCompat.Builder per creare la notifica. Permette il nuovo design delle notifiche (incluso il big-text per le notifiche espandibili) con il supporto per lo stile di notifica più vecchio. È quindi possibile impostare il colore di notifica utilizzando setLights. Inoltre, hai bisogno di un oggetto di notifica che puoi ottenere dall'oggetto costruttore usando getNotification().

NotificationCompat.Builder notify = new NotificationCompat.Builder(context); 
notify.setLights(Color.argb(255, 255, 0, 0), 5000, 5000); 
notify.setSmallIcon(R.drawable.ic_stat_kw); 
notify.setContentTitle("Title"); 
notify.setContentText("Text"); 

Intent showIntent = new Intent(context, MainActivity.class); 
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, showIntent, 0); 
notify.setContentIntent(contentIntent); 

NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
notificationManager.notify(0, notify.getNotification()); 

Spero che questo aiuti ..