i’m trying to authorize my mobile app with facebook, but when facebook authorization window is closed, it doesn’t come back to my application’s continueLoading(1) method..
can’t understand why:
private void authorizeFacebook(final Loader loader) {
String[] permissions = new String[] {"friends_status", "user_status"};
facebook.authorize(this, permissions , new DialogListener() {
@Override
public void onComplete(Bundle values) {
Log.e("finish", "oncomplete");
//SharedPreferences.Editor editor = mPrefs.edit();
//editor.putString("access_token", facebook.getAccessToken());
//editor.putLong("access_expires", facebook.getAccessExpires());
//editor.commit();
loader.continueLoading(1);
}
@Override
public void onFacebookError(FacebookError error) {
Log.i("FacebookAuthorize", error.toString());
app.alert("Facebook Connection Error", "Please try to re-open the application", "Ok", loader);
}
@Override
public void onError(DialogError e) {
Log.i("FacebookAuthorize", e.toString());
app.alert("Facebook Connection Error", "Please try to re-open the application", "Ok", loader);
}
@Override
public void onCancel() {
Log.i("FacebookAuthorize", "onCancel");
app.alert("Facebook Connection Error", "Please try to re-open the application", "Ok", loader);
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
}
the first step of the loader:
private void continueLoading(int step) {
switch(step)
{
//loading current user facebook profile
case 1: progressBar.incrementProgressBy(750);
loadingStatus.setText("Getting user's facebook details");
facebookRunner = new AsyncFacebookRunner(facebook);
facebookConnection = new FacebookConnection(this, 1);
facebookRunner.request("me",facebookConnection);
app.setFacebook(facebook);
app.setFacebookRunner(facebookRunner);
break;
instead of coming back to my app, it just close everything..
The facebook android sdk has two different authentication flows:
1) SSO – will be used if the user has installed the facebook app on the same device.
If this is the case then the facebook sdk you are using will start a new intent to the facebook app to authenticate the user against your app.
To be able to know when that’s done you’ll need to add this:
2) If the device does not have the facebook app installed then the SDK will open it’s own dialog for user authentication, in this case the
DialogListenerimplementation you pass to theauthorizemethod will be used.You need to have both (
DialogListenerandonActivityResult) to handle both cases.