i have created notification works on android versions, except on android 3.x
i use notificationcompat without custom remote views. contentintent setted.
this stack trace:
phonestatusbar: couldn't inflate view notification it.ettore.calcolielettrici/0x647980 android.content.res.resources$notfoundexception: resource id #0x1090087 @ android.content.res.resources.getvalue(resources.java:1014) @ android.content.res.resources.loadxmlresourceparser(resources.java:2039) @ android.content.res.resources.getlayout(resources.java:853) @ android.view.layoutinflater.inflate(layoutinflater.java:389) @ android.widget.remoteviews.apply(remoteviews.java:1490) @ com.android.systemui.statusbar.phone.phonestatusbar.makenotificationview(phonestatusbar.java:529) @ com.android.systemui.statusbar.phone.phonestatusbar.addnotificationviews(phonestatusbar.java:558) @ com.android.systemui.statusbar.phone.phonestatusbar.addnotification(phonestatusbar.java:339) @ com.android.systemui.statusbar.commandqueue$h.handlemessage(commandqueue.java:218) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:126) @ android.app.activitythread.main(activitythread.java:3997) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:491) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:841) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:599) @ dalvik.system.nativestart.main(native method)
and code:
final notificationcompat.builder notificationbuilder = new notificationcompat.builder(context); notificationbuilder.setsmallicon(r.drawable.ic_update_white_24dp); notificationbuilder.setlargeicon(bitmapfactory.decoderesource(context.getresources(), residiconanotifica)); notificationbuilder.setcontenttitle(context.getstring(r.string.notif_upd_aggiornamento_disponibile)); final string contenttext = string.format("%s \"%s\"…", context.getstring(r.string.notif_upd_tap_per_aggiornare), context.getstring(residappname)); notificationbuilder.setcontenttext(contenttext); notificationbuilder.setstyle(new notificationcompat.bigtextstyle().bigtext(contenttext)); notificationbuilder.setautocancel(true); final intent marketintent = storemanager.getintentmarket(context.getpackagename()); final pendingintent aggiornapendingintent = pendingintent.getactivity(context, 0, marketintent, pendingintent.flag_cancel_current); final intent annullaintentreceiver = new intent(notificationupdatecancelreceiver.name); annullaintentreceiver.putextra(key_notification_id, notificationid); annullaintentreceiver.putextra(key_azione, azione_annulla); final pendingintent annullapendingintentreceiver = pendingintent.getbroadcast(context, 0, annullaintentreceiver, pendingintent.flag_cancel_current); final intent marketintentreceiver = new intent(notificationupdatecancelreceiver.name); marketintentreceiver.putextra(key_notification_id, notificationid); marketintentreceiver.putextra(key_azione, azione_aggiorna); marketintentreceiver.putextra(intent.extra_intent, marketintent); final pendingintent aggiornapendingintentreceiver = pendingintent.getbroadcast(context, 1, marketintentreceiver, pendingintent.flag_cancel_current); notificationbuilder.setcontentintent(aggiornapendingintent); notificationbuilder.addaction(new notificationcompat.action(r.drawable.ic_clear_white_24dp, context.getstring(r.string.notif_upd_annulla), annullapendingintentreceiver)); notificationbuilder.addaction(new notificationcompat.action(r.drawable.ic_update_white_24dp, context.getstring(r.string.notif_upd_aggiorna), aggiornapendingintentreceiver)); final notification notification = notificationbuilder.build(); notification.flags |= notification.flag_auto_cancel; final notificationmanager notificationmanager = (notificationmanager) context.getsystemservice(context.notification_service); notificationmanager.notify(notificationid, notification);
thank help
update
i have solved with:
if(build.version.sdk_int >= 14) { notificationbuilder.setlargeicon(bitmapfactory.decoderesource(context.getresources(), residiconanotifica)); }
Comments
Post a Comment