I'm not sure, I didn't build a project with FB API, not yet but I will try to help you. As far as I can read, you need to separate the request of read and publish permissions.
According to the FB API Docs:
Apps should separate the request of read and publish permissions. Plan your app around requesting the bare minimum of read permissions at initial login and then any publish permissions when a person actually needs them.
So, your code might be:
/*
* login to facebook
*/
private void logInToFacebook() {
//...
if (!session.isOpened() && !session.isClosed()) {
session.openForRead(new Session.OpenRequest(this)
.setPermissions(Arrays.asList("basic_info"))
.setCallback(this));
} else {
Session.openActiveSession(this, true, this);
}
}
/*
* set the publish_actions permission here
*/
private void publishFeedDialog() {
Session session = Session.getActiveSession();
// check the session
if (session != null){
// create a new permission
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, Arrays.asList("publish_actions"));
// set a new publish permission request
session.requestNewPublishPermissions(newPermissionsRequest);
Bundle params = new Bundle();
//...
}
}
Maybe this answer might help you with this: SSO (Singe Sign-On) not working when Facebook app is installed on device: he does this on the call
method and he said:
Since call() gets called anytime there is a change in the Session, the session.isOpen() will be true, if we do not check if the permission is set, we will enter in an infinite loop.
You have this information about requestNewPublishPermissions
on the docs:
This method is used to request permissions in addition to what the app has already been granted. This happens after an initial connection has been made to Facebook.
I saw this solution on this step: Add Publishing Logic hence you can read:
The method will first check if the logged-in user has granted your app publish permissions; if they have not, they will be prompted to reauthorize the app and grant the missing permissions.
I hope this will help you.