如何在单次登录时放置facebook readpermission和发布权限。这是我的代码
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_main);
callbackManager = CallbackManager.Factory.create();
loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton = (LoginButton) view.findViewById(R.id.login_button);
loginButton.setReadPermissions(Arrays.asList("public_profile", "email", "user_friends", "user_games_activity"));
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
public void onSuccess(LoginResult loginResult) {
setData(loginResult);
}
public void onCancel() {
Toast.makeText(getApplicationContext(), "CANCEL", Toast.LENGTH_SHORT).show();
}
public void onError(FacebookException e) {
Toast.makeText(getApplicationContext(), "ERROR", Toast.LENGTH_SHORT).show();}
});}
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
LoginManager.getInstance().logInWithPublishPermissions(
BrainSpeed_MainActivity.this,
Arrays.asList("publish_actions"));
}
当facebook活动完成后,callbackmanager总是回电。