facebook android sdk 3.0 login another activity crash -
i use android sdk 3.0 login code session in mainactivity can run ..
but move new activtiy fb.java.can't run .click button crash..
plase how fix:
mainactivity.java code
public void fbautotest(view v){ fb myffb=new fb(); myffb.facebooklogin();}
fb.java code
public class fb extends activity{ private static final list<string> permissions = arrays.aslist("publish_actions","user_photos"); private pendingaction pendingaction = pendingaction.none; private enum pendingaction { none, post_photo, post_status_update } private statuscallback callback; //private activity mcontext; private activity mcontext; public void facebooklogin() { session.openactivesession(mcontext, true, new session.statuscallback() { // callback when session changes state @override public void call(session session, sessionstate state, exception exception) { if (session.isopened()) { request.executemerequestasync(session, new request.graphusercallback() { // callback after graph api response user object @override public void oncompleted(graphuser user, response response) { } }); } } }); } }
error code
04-05 06:50:16.246: w/dalvikvm(904): threadid=1: thread exiting uncaught exception (group=0x40a13300) 04-05 06:50:16.326: e/androidruntime(904): fatal exception: main 04-05 06:50:16.326: e/androidruntime(904): java.lang.illegalstateexception: not execute method of activity 04-05 06:50:16.326: e/androidruntime(904): @ android.view.view$1.onclick(view.java:3591) 04-05 06:50:16.326: e/androidruntime(904): @ android.view.view.performclick(view.java:4084) 04-05 06:50:16.326: e/androidruntime(904): @ android.view.view$performclick.run(view.java:16966) 04-05 06:50:16.326: e/androidruntime(904): @ android.os.handler.handlecallback(handler.java:615) 04-05 06:50:16.326: e/androidruntime(904): @ android.os.handler.dispatchmessage(handler.java:92) 04-05 06:50:16.326: e/androidruntime(904): @ android.os.looper.loop(looper.java:137) 04-05 06:50:16.326: e/androidruntime(904): @ android.app.activitythread.main(activitythread.java:4745) 04-05 06:50:16.326: e/androidruntime(904): @ java.lang.reflect.method.invokenative(native method) 04-05 06:50:16.326: e/androidruntime(904): @ java.lang.reflect.method.invoke(method.java:511) 04-05 06:50:16.326: e/androidruntime(904): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:786) 04-05 06:50:16.326: e/androidruntime(904): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 04-05 06:50:16.326: e/androidruntime(904): @ dalvik.system.nativestart.main(native method) 04-05 06:50:16.326: e/androidruntime(904): caused by: java.lang.reflect.invocationtargetexception 04-05 06:50:16.326: e/androidruntime(904): @ java.lang.reflect.method.invokenative(native method) 04-05 06:50:16.326: e/androidruntime(904): @ java.lang.reflect.method.invoke(method.java:511) 04-05 06:50:16.326: e/androidruntime(904): @ android.view.view$1.onclick(view.java:3586) 04-05 06:50:16.326: e/androidruntime(904): ... 11 more 04-05 06:50:16.326: e/androidruntime(904): caused by: java.lang.nullpointerexception: argument 'applicationid' cannot null 04-05 06:50:16.326: e/androidruntime(904): @ com.facebook.internal.validate.notnull(validate.java:29) 04-05 06:50:16.326: e/androidruntime(904): @ com.facebook.session.<init>(session.java:224) 04-05 06:50:16.326: e/androidruntime(904): @ com.facebook.session.<init>(session.java:213) 04-05 06:50:16.326: e/androidruntime(904): @ com.facebook.session$builder.build(session.java:1454) 04-05 06:50:16.326: e/androidruntime(904): @ com.facebook.session.openactivesession(session.java:863) 04-05 06:50:16.326: e/androidruntime(904): @ com.facebook.session.openactivesession(session.java:805) 04-05 06:50:16.326: e/androidruntime(904): @ com.example.mk2weibo.fb.facebooklogin(fb.java:45) 04-05 06:50:16.326: e/androidruntime(904): @ com.example.mk2weibo.mainactivity.fbautotest(mainactivity.java:410) 04-05 06:50:16.326: e/androidruntime(904): ... 14 more
read stacktrace:
4-05 06:50:16.326: e/androidruntime(904): caused by: java.lang.nullpointerexception: argument 'applicationid' cannot null
Comments
Post a Comment