开发者

Facebook Authentication with Facebook app error

开发者 https://www.devze.com 2023-03-08 04:07 出处:网络
I followed the instructions here, and it works fine, when the Facebook App is not installed. When the official Facebook App is installed, the callback are not called after calling authorize, and I don

I followed the instructions here, and it works fine, when the Facebook App is not installed. When the official Facebook App is installed, the callback are not called after calling authorize, and I don't get back the token. When the app is installed, the shiny login screen comes up (from the Facebook app), when it's not, the webview. I searched a lot, but every tutorial says I should use the sample from the page I linked. What am I missing?

开发者_如何转开发
// Facebook connect
public void facebookConnect(View v) {
    /* CocktailflowTest AppID */
    final Facebook facebook = new Facebook("134370943293463");
    facebook.authorize(this, new String[] { "email", "offline_access" }, new DialogListener() {

        @Override
        public void onFacebookError(FacebookError e) {
            e.getMessage();
        }

        @Override
        public void onError(DialogError e) {
            Toast.makeText(LaunchActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onComplete(Bundle values) {
            mFBToken = facebook.getAccessToken();
            getPreferences(MODE_PRIVATE).edit().putString(Prefs.FACEBOOK_TOKEN, mFBToken).commit();
            WebService service = new WebService();
            WebServiceListener l = new LaunchWebserviceListener();
            mDialog = ProgressDialog.show(LaunchActivity.this, "", "Logging in...");
            mDialog.show();
            service.connectWithFacebook(l, mFBToken);
        }

        @Override
        public void onCancel() {
            Log.i(TAG, "Facebook connect was cancelled by user.");
        }
    });
}


You need to override the onActivityResult method in your Activity:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    facebook.authorizeCallback(requestCode, resultCode, data);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消