android - Notification in Service on isolated process throws NPE -
i nullpointer, every time try send notification service runs on isolted service.
the exception:
java.lang.nullpointerexception @ android.app.notificationmanager.notify(notificationmanager.java:136) @ android.app.notificationmanager.notify(notificationmanager.java:109) @ de.nwo.client.modules.service.nwoservice.createorupdatenotification(nwoservice.java:66) @ de.nwo.client.modules.service.nwoservice.access$000(nwoservice.java:23) @ de.nwo.client.modules.service.nwoservice$1.run(nwoservice.java:47) @ android.os.handler.handlecallback(handler.java:730) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:5103) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:525) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) @ dalvik.system.nativestart.main(native method)
manifest declaration:
<service android:name=".modules.service.nwoservice" android:exported="false" android:isolatedprocess="true" android:process=":nwoservice"/>
the service implementation:
@override public int onstartcommand(intent intent, int flags, int startid) { log.d(service_tag,"started!"); startlogging(); return service.start_sticky; } private void startlogging() { handler handler = new handler(); handler.postdelayed(new runnable() { @override public void run() { createorupdatenotification(); startlogging(); } },3000); } private void createorupdatenotification(){ notificationcompat.builder builder = new notificationcompat.builder(this); builder .setsmallicon(r.mipmap.ic_launcher) .setpriority(notification.priority_max) .setcolor(color.green) .setongoing(true) .setcontenttext(string.valueof(++increment)) .setcontenttitle("nwo"); notificationmanager mnotificationmanager = (notificationmanager) getsystemservice(context.notification_service); notification f = builder.build(); log.d(service_tag, "nm: " + mnotificationmanager + " , notification: " + f); mnotificationmanager.notify(notificationid, f); //npe here }
if remove lines android:isolatedprocess="true" , android:process=":nwoservice" manfiset, works intended. know reason? why can't use notificationmanager isolated process?
Comments
Post a Comment