android - Unable to start receiver exception -
problem: time time application throws en exception on start, not always. don't understand why times happens, times not. suggestion appreciated.
some log:
04-18 17:58:12.437: e/androidruntime(26208): fatal exception: main 04-18 17:58:12.437: e/androidruntime(26208): java.lang.runtimeexception: unable start receiver com.cm.clou.contactslistupdatereceiver: java.lang.nullpointerexception 04-18 17:58:12.437: e/androidruntime(26208): @ android.app.activitythread.handlereceiver(activitythread.java:1805) 04-18 17:58:12.437: e/androidruntime(26208): @ android.app.activitythread.access$2400(activitythread.java:117) 04-18 17:58:12.437: e/androidruntime(26208): @ android.app.activitythread$h.handlemessage(activitythread.java:981) 04-18 17:58:12.437: e/androidruntime(26208): @ android.os.handler.dispatchmessage(handler.java:99) 04-18 17:58:12.437: e/androidruntime(26208): @ android.os.looper.loop(looper.java:130) 04-18 17:58:12.437: e/androidruntime(26208): @ android.app.activitythread.main(activitythread.java:3683) 04-18 17:58:12.437: e/androidruntime(26208): @ java.lang.reflect.method.invokenative(native method) 04-18 17:58:12.437: e/androidruntime(26208): @ java.lang.reflect.method.invoke(method.java:507) 04-18 17:58:12.437: e/androidruntime(26208): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 04-18 17:58:12.437: e/androidruntime(26208): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 04-18 17:58:12.437: e/androidruntime(26208): @ dalvik.system.nativestart.main(native method) 04-18 17:58:12.437: e/androidruntime(26208): caused by: java.lang.nullpointerexception 04-18 17:58:12.437: e/androidruntime(26208): @ com.cm.clou.conversationslistactivity.notifyadaper(conversationslistactivity.java:270) 04-18 17:58:12.437: e/androidruntime(26208): @ com.cm.clou.contactslistupdatereceiver.onreceive(contactslistupdatereceiver.java:17) 04-18 17:58:12.437: e/androidruntime(26208): @ android.app.activitythread.handlereceiver(activitythread.java:1794)
receiver's code:
public class contactslistupdatereceiver extends broadcastreceiver { public static final string tag = contactslistupdatereceiver.class.getsimplename(); @override public void onreceive(context context, intent intent) { string message = intent.getstringextra("message"); if (message != null) { log.d(tag, "uslishali otvet ot servisa po apdejtu contactov: " + message); conversationslistactivity.notifyadaper(context); } } }
in manifest:
<receiver android:name="com.cm.clou.contactslistupdatereceiver" android:enabled="true" android:exported="false" > <intent-filter> <action android:name="com.cm.clou.action_contacts_list_update" /> </intent-filter> </receiver>
and notifyadaper's code:
private static conversationslistcursoradapter conversationslistcursoradapter = null; @suppresslint("newapi") public static void notifyadaper(context context) { uri uri = cloucontentprovider.conversations_content_uri; cursor cursor = null; if (android.os.build.version.sdk_int < 11) { cursor = context.getcontentresolver().query(uri, null, null, null, null); } else { cursorloader cursorloader = new cursorloader(context, uri, null, null, null, null); cursor = cursorloader.loadinbackground(); } conversationslistcursoradapter.changecursor(cursor); conversationslistcursoradapter.notifydatasetchanged(); }
looks never instantiate conversationslistcursoradapter
.
you need instantiate before accessing it.
Comments
Post a Comment