问题
I have searched a lot for past two days and I was not successful. I am following the Authenticate-Facebook Developers link for setting up the Facebook native login. I add the following code to SplashFragment.java
:
authButton = (LoginButton) view.findViewById(R.id.fb_logIn_btn);
authButton.setPublishPermissions(PERMISSION);
authButton.setDefaultAudience(SessionDefaultAudience.ONLY_ME);
But this does not work.
In my app, I want to alert the user to enter the privacy mode(SessionDefaultAudience.EVERYONE
or SessionDefaultAudience.ONLY_ME
or SessionDefaultAudience.FRIENDS
) to set their privacy setting for their post through the application.
I also went through Session.NewPermissionsRequest-Facebook Developers but how to implement this?
回答1:
You can change the audience and the Permission like that:
private void requestPublishPermissions(Session session) {
if (session != null && !session.getPermissions().contains("publish_actions")) {
System.out.println("SEESION Permission");
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(mainFragment, Arrays.asList("publish_actions"));
// demonstrate how to set an audience for the publish permissions,
// if none are set, this defaults to FRIENDS
.setDefaultAudience(SessionDefaultAudience.FRIENDS);
session.requestNewPublishPermissions(newPermissionsRequest);
}
}
Just change this line to the audience you want
.setDefaultAudience(SessionDefaultAudience.FRIENDS);
来源:https://stackoverflow.com/questions/15738324/how-to-set-sessiondefaultaudience-for-facebook-in-android