0
我使用3.6來實現Facebook登錄。從官方文件來看,它非常抽象,不容易遵循。所以我在網上找到了一些教程。但是,當我使用該教程中的代碼時,它說該方法已被棄用。雖然它有效,但我擔心官方稍後會停止該功能。那麼,是否有任何方法可以實現登錄/發佈到牆上/獲取最新sdk的個人信息?由於最新的方法來實現登錄通過facebook sdk在android
登錄代碼:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lblEmail = (TextView) findViewById(R.id.t);
LoginButton authButton = (LoginButton) findViewById(R.id.authButton);
authButton.setOnErrorListener(new OnErrorListener() {
@Override
public void onError(FacebookException error) {
Log.i(TAG, "Error " + error.getMessage());
}
});
// set permission list, Don't foeget to add email
authButton.setReadPermissions(Arrays.asList("basic_info", "email"));
// session state call back event
authButton.setSessionStatusCallback(new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state,
Exception exception) {
if (session.isOpened()) {
Log.i(TAG, "Access Token" + session.getAccessToken());
Request.executeMeRequestAsync(session,
new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user,
Response response) {
if (user != null) {
Log.i(TAG, "User ID " + user.getId());
Log.i(TAG,
"Email "
+ user.asMap().get(
"email"));
lblEmail.setText(user.asMap()
.get("email").toString());
}
}
});
}
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode,
resultCode, data);
}
在代碼Request.executeMeRequestAsync是貶低