I use android sdk 3.0 login code Session in the MainActivity can run ..
but I move to new Activtiy FB.JAVA.can't run .click button crash..
plase how to 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 ListPERMISSIONS = 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 with 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 with 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: Could not execute method of the activity
04-05 06:50:16.326: E/AndroidRuntime(904): at android.view.View$1.onClick(View.java:3591)
04-05 06:50:16.326: E/AndroidRuntime(904): at android.view.View.performClick(View.java:4084)
04-05 06:50:16.326: E/AndroidRuntime(904): at android.view.View$PerformClick.run(View.java:16966)
04-05 06:50:16.326: E/AndroidRuntime(904): at android.os.Handler.handleCallback(Handler.java:615)
04-05 06:50:16.326: E/AndroidRuntime(904): at android.os.Handler.dispatchMessage(Handler.java:92)
04-05 06:50:16.326: E/AndroidRuntime(904): at android.os.Looper.loop(Looper.java:137)
04-05 06:50:16.326: E/AndroidRuntime(904): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-05 06:50:16.326: E/AndroidRuntime(904): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 06:50:16.326: E/AndroidRuntime(904): at java.lang.reflect.Method.invoke(Method.java:511)
04-05 06:50:16.326: E/AndroidRuntime(904): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-05 06:50:16.326: E/AndroidRuntime(904): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-05 06:50:16.326: E/AndroidRuntime(904): at 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): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 06:50:16.326: E/AndroidRuntime(904): at java.lang.reflect.Method.invoke(Method.java:511)
04-05 06:50:16.326: E/AndroidRuntime(904): at 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 be null
04-05 06:50:16.326: E/AndroidRuntime(904): at com.facebook.internal.Validate.notNull(Validate.java:29)
04-05 06:50:16.326: E/AndroidRuntime(904): at com.facebook.Session.(Session.java:224)
04-05 06:50:16.326: E/AndroidRuntime(904): at com.facebook.Session.(Session.java:213)
04-05 06:50:16.326: E/AndroidRuntime(904): at com.facebook.Session$Builder.build(Session.java:1454)
04-05 06:50:16.326: E/AndroidRuntime(904): at com.facebook.Session.openActiveSession(Session.java:863)
04-05 06:50:16.326: E/AndroidRuntime(904): at com.facebook.Session.openActiveSession(Session.java:805)
04-05 06:50:16.326: E/AndroidRuntime(904): at com.example.mk2weibo.fb.facebookLogin(fb.java:45)
04-05 06:50:16.326: E/AndroidRuntime(904): at com.example.mk2weibo.MainActivity.fbautotest(MainActivity.java:410)
04-05 06:50:16.326: E/AndroidRuntime(904): ... 14 more
.
stackoverflow.comm
No comments:
Post a Comment