开发者

onComplete method is not called on htc desire

开发者 https://www.devze.com 2023-03-22 11:50 出处:网络
I am implementing a Facebook login facility on Android which seems to work OK on the emulator and on Google Nexus device. However the authorization seems to be cancelled by the user on HTC Desire S an

I am implementing a Facebook login facility on Android which seems to work OK on the emulator and on Google Nexus device. However the authorization seems to be cancelled by the user on HTC Desire S and so the onComplete() is never called. The only difference I found is that HTC has a built in facebook application. This is the code I am using:

private void Login(){
    facebook.authorize(this,new String[] {"email"}, new Facebook.DialogListener() {
        @Override
        public void onComplete(Bundle values) {
            Log.d("Auth","onCompleteCalled");

        }

        @Override
        public void onFacebookError(FacebookError error) {}

        @Override
        public void onError(DialogError e) {}

        @Override
        public void onCancel() {
            Log.d("Auth","Cancelled");

        }
    });

The error message comes from this section of Facebook SDK code:

} else if (resultCode == Activity.RESULT_CANCELED) {

            // An Android error occured.
            if (data != null) {
                Log.d("Facebook-auth开发者_如何学Pythonorize",
                        "Login failed: " + data.getStringExtra("error"));
                mAuthDialogListener.onError(
                        new DialogError(
                                data.getStringExtra("error"),
                                data.getIntExtra("error_code", -1),
                                data.getStringExtra("failing_url")));

            // User pressed the 'back' button.
            } else {
                Log.d("Facebook-authorize", "Login canceled by user."); //This is the error I get
                mAuthDialogListener.onCancel();
            }


Please Update below code of your application, it will solve your problem.

public void loginAndPostToWall() {
    facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH,
            new LoginDialogListener());
}
0

精彩评论

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

关注公众号