java - Getting null pointer exception on callbackmanager -
i'm using facebook sdk. when logging, i'm getting nullpointer exception,
loginbutton loginbutton; callbackmanager callbackmanager; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); callbackmanager = callbackmanager.factory.create(); facebooksdk.sdkinitialize(getapplicationcontext()); setcontentview(r.layout.activity_main); loginbutton = (loginbutton)findviewbyid(r.id.login_button); list<string> permissionneeds = arrays.aslist("user_photos", "email", "user_birthday", "public_profile"); loginbutton.setreadpermissions(permissionneeds); loginbutton.registercallback(callbackmanager, new facebookcallback<loginresult>() { @override public void onsuccess(loginresult loginresult) { system.out.println("onsuccess"); } @override public void oncancel() { system.out.println("oncancel"); } @override public void onerror(facebookexception exception) { log.v("loginactivity", exception.getcause().tostring()); } }); } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); callbackmanager.onactivityresult(requestcode, resultcode, data); }
the error raising method onactivityresult on second line, callbackmanager.onactivityresult(requestcode, resultcode, data);.
part of stacktrace:
06-20 14:07:52.253 21310-21310/com.itspirits.fbchatdownloader e/androidruntime﹕ fatal exception: main process: com.itspirits.fbchatdownloader, pid: 21310 java.lang.runtimeexception: failure delivering result resultinfo{who=null, request=64206, result=-1, data=intent { (has extras) }} activity {com.itspirits.fbchatdownloader/com.itspirits.fbchatdownloader.mainactivity}: java.lang.nullpointerexception @ android.app.activitythread.deliverresults(activitythread.java:3365) @ android.app.activitythread.handlesendresult(activitythread.java:3408) @ android.app.activitythread.access$1300(activitythread.java:135) @ android.app.activitythread$h.handlemessage(activitythread.java:1244) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:136) @ android.app.activitythread.main(activitythread.java:5017) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:515) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) @ dalvik.system.nativestart.main(native method) caused by: java.lang.nullpointerexception @ com.itspirits.fbchatdownloader.mainactivity$1.onerror(mainactivity.java:53) @ com.facebook.login.loginmanager.finishlogin(loginmanager.java:507) @ com.facebook.login.loginmanager.onactivityresult(loginmanager.java:192) @ com.facebook.login.loginmanager$1.onactivityresult(loginmanager.java:140) @ com.facebook.internal.callbackmanagerimpl.onactivityresult(callbackmanagerimpl.java:82) @ com.itspirits.fbchatdownloader.mainactivity.onactivityresult(mainactivity.java:69) @ android.app.activity.dispatchactivityresult(activity.java:5423) @ android.app.activitythread.deliverresults(activitythread.java:3361) at android.app.activitythread.handlesendresult(activitythread.java:3408) at android.app.activitythread.access$1300(activitythread.java:135) at android.app.activitythread$h.handlemessage(activitythread.java:1244) at android.os.handler.dispatchmessage(handler.java:102) at android.os.looper.loop(looper.java:136) at android.app.activitythread.main(activitythread.java:5017) at java.lang.reflect.method.invokenative(native method) at java.lang.reflect.method.invoke(method.java:515) at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) at com.android.internal.os.zygoteinit.main(zygoteinit.java:595) at dalvik.system.nativestart.main(native method)
is callbackmanager null? data null? (unlikely)
you can simple debuging printing variables before use see , when null :-)
Comments
Post a Comment