我在我的应用程序中使用 Action bar sherlock 库,我目前有一个两个选项卡作为片段:
选项卡 A:用户查看列表中的信息选项卡 B:用户可以登录 facebook
我需要 onActivityResult() 来处理选项卡 B 中的 Facebook 会话,因此我的 Main Activity 中有以下代码:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
但是,当我按下选项卡 A 中的后退按钮时,这会创建此错误日志:
04-02 19:46:07.488: E/AndroidRuntime(1380): FATAL EXCEPTION: main
04-02 19:46:07.488: E/AndroidRuntime(1380): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65537, result=0, data=null} to activity {com.example.chartviewer/com.example.chartviewer.MainActivity}: java.lang.NullPointerException
04-02 19:46:07.488: E/AndroidRuntime(1380): at android.app.ActivityThread.deliverResults(ActivityThread.java:3141)
04-02 19:46:07.488: E/AndroidRuntime(1380): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3184)
04-02 19:46:07.488: E/AndroidRuntime(1380): at android.app.ActivityThread.access$1100(ActivityThread.java:130)
04-02 19:46:07.488: E/AndroidRuntime(1380): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1243)
04-02 19:46:07.488: E/AndroidRuntime(1380): at android.os.Handler.dispatchMessage(Handler.java:99)
04-02 19:46:07.488: E/AndroidRuntime(1380): at android.os.Looper.loop(Looper.java:137)
04-02 19:46:07.488: E/AndroidRuntime(1380): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-02 19:46:07.488: E/AndroidRuntime(1380): at java.lang.reflect.Method.invokeNative(Native Method)
04-02 19:46:07.488: E/AndroidRuntime(1380): at java.lang.reflect.Method.invoke(Method.java:511)
04-02 19:46:07.488: E/AndroidRuntime(1380): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-02 19:46:07.488: E/AndroidRuntime(1380): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-02 19:46:07.488: E/AndroidRuntime(1380): at dalvik.system.NativeStart.main(Native Method)
04-02 19:46:07.488: E/AndroidRuntime(1380): Caused by: java.lang.NullPointerException
04-02 19:46:07.488: E/AndroidRuntime(1380): at com.example.chartviewer.MainActivity.onActivityResult(MainActivity.java:91)
04-02 19:46:07.488: E/AndroidRuntime(1380): at android.app.Activity.dispatchActivityResult(Activity.java:5192)
04-02 19:46:07.488: E/AndroidRuntime(1380): at android.app.ActivityThread.deliverResults(ActivityThread.java:3137)
04-02 19:46:07.488: E/AndroidRuntime(1380): ... 11 more
知道如何处理吗?