我已经在我的安卓应用中使用LoginButton进行了Facebook登录检查,但我想使用LoginManager进行检查。我该如何修改代码使其能够实现这个功能?
LoginButton loginButton = (LoginButton) findViewById(R.id.fb_login_button);
loginButton.setReadPermissions("user_friends");
shareDialog = new ShareDialog(this);
//Login Callback registration
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Toast.makeText(getApplicationContext(), "in LoginResult on success", Toast.LENGTH_LONG).show();
//Login success - process to Post
if (ShareDialog.canShow(ShareLinkContent.class)) {
String description = "description";
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("title")
.setContentDescription(description)
.setContentUrl(Uri.parse("http://google.com"))
.setImageUrl(Uri.parse("http://google.com"))
.build();
shareDialog.show(linkContent, ShareDialog.Mode.FEED);
}
}
@Override
public void onCancel() {
Toast.makeText(getApplicationContext(), "in LoginResult on cancel", Toast.LENGTH_LONG).show();
}
@Override
public void onError(FacebookException exception) {
Toast.makeText(getApplicationContext(), "in LoginResult on error", Toast.LENGTH_LONG).show();
}
});
如果用户在打开共享对话框之前未登录,则我希望您能打开Facebook登录对话框。登录对话框应与共享对话框相同(在弹出窗口中)。如何实现?谢谢!