大家都在公开的Facebook墙上发布自定义数据。这在没有安装Facebook应用程序的设备上运行正常。但是在安装了facebook的设备上,access_token
为空,我无法共享文本。
new Session(UserShareActivity.this).openForPublish(new Session.OpenRequest(UserShareActivity.this).setPermissions(PERMISSIONS).setCallback(new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
Bundle postParams = new Bundle();
postParams.putString("message", getIntent().getStringExtra("message"));
postParams.putString("access_token", session.getAccessToken());
Log.d("pageID", prefs.getString(Strings.pageID, ""));
Log.d("getAccessToken", "" + session.getAccessToken());
Request request = new Request(null, prefs.getString(Strings.pageID, "") + "/feed", postParams, HttpMethod.POST, callback);
RequestAsyncTask newtask = new RequestAsyncTask(request);
newtask.execute();
}
}
}));
传递回调的 OnActivityResult()
方法:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try{
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}catch(Exception e){
e.printStackTrace();
}
}