我是 Facebook SDK (3) 的新手,并且已成功编译并运行 HelloFacebookSample。现在我只想发布一个墙贴,所以我试图删除所有不必要的东西,只有发布状态功能
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton);
postStatusUpdateButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
onClickPostStatusUpdate();
}
});
}
private void onClickPostStatusUpdate() {
performPublish(PendingAction.POST_STATUS_UPDATE);
}
private void performPublish(PendingAction action) {
Session session = Session.getActiveSession();
if (session != null) {
pendingAction = action;
if (hasPublishPermission()) {
// We can do the action right away.
handlePendingAction();
} else {
// We need to reauthorize, then complete the action when we get called back.
Session.ReauthorizeRequest reauthRequest = new Session.ReauthorizeRequest(this, PERMISSIONS).
setRequestCode(REAUTHORIZE_ACTIVITY).
setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);
session.reauthorizeForPublish(reauthRequest);
}
}
}
但是在 performPublish 会话上为空。