当我点击按钮时,应用程序停止了。
public class MainActivity extends ListActivity {
private Facebook mFacebook;
Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
dialogButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
postToWall();
}
});
dialog.show();
}
public void postToWall() {
Bundle parameters = new Bundle();
parameters.putString("description", "description about link");
parameters.putString("picture","link of picture your want add with share post.");
parameters.putString("link", "Link you want to share");
parameters.putString("name","Name of link");
parameters.putString("caption","describe your caption text");
mFacebook.dialog(this, "stream.publish", parameters,new DialogListener() {
@Override
public void onFacebookError(FacebookError arg0) {
}
public void onError(DialogError arg0) {
}
public void onComplete(Bundle arg0) {
}
public void onCancel() {
}
});
}
堆栈跟踪:
12-14 21:26:11.198: E/AndroidRuntime(1021): FATAL EXCEPTION: main
12-14 21:26:11.198: E/AndroidRuntime(1021): java.lang.NullPointerException
12-14 21:26:11.198: E/AndroidRuntime(1021): at com.example.imdb.Display.postToWall(Display.java:447)
12-14 21:26:11.198: E/AndroidRuntime(1021): at com.example.imdb.Display$1.onClick(Display.java:399)
12-14 21:26:11.198: E/AndroidRuntime(1021): at android.view.View.performClick(View.java:4202)
12-14 21:26:11.198: E/AndroidRuntime(1021): at android.view.View$PerformClick.run(View.java:17340)
12-14 21:26:11.198: E/AndroidRuntime(1021): at android.os.Handler.handleCallback(Handler.java:725)
12-14 21:26:11.198: E/AndroidRuntime(1021): at android.os.Handler.dispatchMessage(Handler.java:92)
12-14 21:26:11.198: E/AndroidRuntime(1021): at android.os.Looper.loop(Looper.java:137)
12-14 21:26:11.198: E/AndroidRuntime(1021): at android.app.ActivityThread.main(ActivityThread.java:5039)
12-14 21:26:11.198: E/AndroidRuntime(1021): at java.lang.reflect.Method.invokeNative(Native Method)
12-14 21:26:11.198: E/AndroidRuntime(1021): at java.lang.reflect.Method.invoke(Method.java:511)
12-14 21:26:11.198: E/AndroidRuntime(1021): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-14 21:26:11.198: E/AndroidRuntime(1021): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-14 21:26:11.198: E/AndroidRuntime(1021): at dalvik.system.NativeStart.main(Native Method)
另外,有一个警告说不推荐使用Facebook类型的方法对话框(Context,String,Bundle,Facebook.DialogListener)。这有关系吗?如何解决这个问题?