我已经从 Facebook 的 android 教程中复制了注销代码。每次我尝试注销时,都会出现空指针异常。
这是代码...
private AsyncFacebookRunner mAsyncRunner;
...
mAsyncRunner.logout(home.this, new RequestListener() {
@Override
public void onComplete(String response, Object state)
{
/* mPrefs.edit().putBoolean("firstTime", true).commit();
userName.setText("Logged out!");*/
}
@Override
public void onIOException(IOException e, Object state) {
Log.d("IOExcenption", e.toString());
}
@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
Log.d("FileNotFoundException", e.toString());
}
@Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
Log.d("MalformedUrlExpection", e.toString());
}
@Override
public void onFacebookError(FacebookError e, Object state) {
Log.d("FacebookError", e.toString());
}
});
日志
04-29 23:41:35.523: E/AndroidRuntime(1011): java.lang.NullPointerException
04-29 23:41:35.523: E/AndroidRuntime(1011): at rageup.android.home.onClick(home.java:177)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.view.View.performClick(View.java:2364)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.view.View.onTouchEvent(View.java:4179)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.widget.TextView.onTouchEvent(TextView.java:6541)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.view.View.dispatchTouchEvent(View.java:3709)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-29 23:41:35.523: E/AndroidRuntime(1011): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
04-29 23:41:35.523: E/AndroidRuntime(1011): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
04-29 23:41:35.523: E/AndroidRuntime(1011): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.os.Handler.dispatchMessage(Handler.java:99)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.os.Looper.loop(Looper.java:123)
04-29 23:41:35.523: E/AndroidRuntime(1011): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-29 23:41:35.523: E/AndroidRuntime(1011): at java.lang.reflect.Method.invokeNative(Native Method)
04-29 23:41:35.523: E/AndroidRuntime(1011): at java.lang.reflect.Method.invoke(Method.java:521)
04-29 23:41:35.523: E/AndroidRuntime(1011): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-29 23:41:35.523: E/AndroidRuntime(1011): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-29 23:41:35.523: E/AndroidRuntime(1011): at dalvik.system.NativeStart.main(Native Method)
04-29 23:41:35.534: I/dalvikvm(1011): threadid=7: reacting to signal 3
04-29 23:41:35.534: E/dalvikvm(1011): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
04-29 23:41:37.283: I/Process(1011): Sending signal. PID: 1011 SIG: 9
关于为什么会发生这种情况的任何建议?空指针异常是指第二个代码块的第一行。