我一直在尝试在我的应用程序中使用 Facebook SDK,但是当Facebook.authorizeCallback
使用此 Logcat 崩溃报告调用时,应用程序突然开始崩溃:
06-19 13:28:24.335: E/AndroidRuntime(7828): FATAL EXCEPTION: main
06-19 13:28:24.335: E/AndroidRuntime(7828): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=32665, result=-1, data=Intent { (has extras) }} to activity {com.thepoosh/com.thepoosh.CoveActivity}: java.lang.NullPointerException
06-19 13:28:24.335: E/AndroidRuntime(7828): at android.app.ActivityThread.deliverResults(ActivityThread.java:2536)
06-19 13:28:24.335: E/AndroidRuntime(7828): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2578)
06-19 13:28:24.335: E/AndroidRuntime(7828): at android.app.ActivityThread.access$2000(ActivityThread.java:117)
06-19 13:28:24.335: E/AndroidRuntime(7828): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:965)
06-19 13:28:24.335: E/AndroidRuntime(7828): at android.os.Handler.dispatchMessage(Handler.java:99)
06-19 13:28:24.335: E/AndroidRuntime(7828): at android.os.Looper.loop(Looper.java:123)
06-19 13:28:24.335: E/AndroidRuntime(7828): at android.app.ActivityThread.main(ActivityThread.java:3691)
06-19 13:28:24.335: E/AndroidRuntime(7828): at java.lang.reflect.Method.invokeNative(Native Method)
06-19 13:28:24.335: E/AndroidRuntime(7828): at java.lang.reflect.Method.invoke(Method.java:507)
06-19 13:28:24.335: E/AndroidRuntime(7828): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
06-19 13:28:24.335: E/AndroidRuntime(7828): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
06-19 13:28:24.335: E/AndroidRuntime(7828): at dalvik.system.NativeStart.main(Native Method)
06-19 13:28:24.335: E/AndroidRuntime(7828): Caused by: java.lang.NullPointerException
06-19 13:28:24.335: E/AndroidRuntime(7828): at com.thepoosh.myActivity$1.onComplete(CoveActivity.java:124)
06-19 13:28:24.335: E/AndroidRuntime(7828): at com.facebook.android.Facebook.authorizeCallback(Facebook.java:433)
06-19 13:28:24.335: E/AndroidRuntime(7828): at com.thepoosh.myActivity.onActivityResult(CoveActivity.java:191)
06-19 13:28:24.335: E/AndroidRuntime(7828): at android.app.Activity.dispatchActivityResult(Activity.java:3934)
06-19 13:28:24.335: E/AndroidRuntime(7828): at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
06-19 13:28:24.335: E/AndroidRuntime(7828): ... 11 more
这是我的代码:
public final String[] PERMISSIONS = {};
private final String APPID = "239304262850291";
public final Facebook FACEBOOK = new Facebook(APPID);
private void loginAndAuthorize() {
FACEBOOK.authorize(CoveActivity.this,PERMISSIONS,
new DialogListener() {
@Override
public void onFacebookError(FacebookError e) {
Log.e(TAG, "Facebook error: " + e.getMessage());
Toast.makeText(Activity.this,
"there was an error connecting to Facebook",
Toast.LENGTH_LONG).show();
dialog.dismiss();
}
@Override
public void onError(DialogError e) {
Log.e(TAG, "General error: " + e.getMessage());
Toast.makeText(Activity.this,
"there was an error connecting to Facebook",
Toast.LENGTH_LONG).show();
dialog.dismiss();
}
@Override
public void onComplete(Bundle values) {
isLogged = true;
/* DO STUFF WITH INFORMATION */
}
@Override
public void onCancel() {
Log.d(TAG, "facebook login Cancelled");
Toast.makeText(Activity.this, "Login Cancelled",
Toast.LENGTH_LONG).show();
dialog.dismiss();
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
FACEBOOK.authorizeCallback(requestCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}
关于如何解决这个问题的任何想法?(它曾经工作到 5 分钟前......)