htcdesire 上未调用 onComplete 方法

发布于 2024-11-25 10:26:57 字数 1511 浏览 1 评论 0原文

我正在 Android 上实现 Facebook 登录工具,该工具似乎在模拟器和 Google Nexus 设备上运行正常。然而,用户似乎在 HTC Desire S 上取消了授权,因此永远不会调用 onComplete()。我发现的唯一区别是 HTC 有一个内置的 Facebook 应用程序。这是我正在使用的代码:

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");

        }
    });

错误消息来自 Facebook SDK 代码的这一部分:

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

            // An Android error occured.
            if (data != null) {
                Log.d("Facebook-authorize",
                        "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();
            }

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-authorize",
                        "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();
            }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自由如风 2024-12-02 10:26:57

请更新您的应用程序的以下代码,它将解决您的问题。

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

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());
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文