我开发了 facebook 应用程序,但是当它安装到设备上时,如果设备上没有安装 facebook 应用程序,并且当 facebook 应用程序安装时会话无法打开,则它可以正常工作。我的代码如下,
Session.openActiveSession(this, true,
new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(Session session, SessionState state,
Exception exception) {
if (session.isOpened()) {
// make request to the /me API
Request.executeMeRequestAsync(session,
new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user,
Response res) {
if (user != null) {
User.getInstance().setProfile(user);
}
}
});
}
}
});
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
if(Session.getActiveSession().isOpened()) {
Log.i("here opened", "thnx");
}
}