简体   繁体   English

从我的应用程序登录到Facebook可以在模拟器上运行但不在设备上运行

[英]logging in to facebook from my app works on emulator but not on device

This is my code for logging in to facebook. 这是我登录Facebook的代码。

mLoginButton = (LoginButton) findViewById(R.id.login);

        // restore session if one exists
        SessionStore.restore(Utility.mFacebook, this);
        SessionEvents.addAuthListener(new FbAPIsAuthListener());
        SessionEvents.addLogoutListener(new FbAPIsLogoutListener());

        /*
         * Source Tag: login_tag
         */
        mLoginButton.init(this, AUTHORIZE_ACTIVITY_RESULT_CODE, Utility.mFacebook, permissions);

        if (Utility.mFacebook.isSessionValid()) {
            requestUserData();
        }
 public class FbAPIsAuthListener implements AuthListener {

        //@Override
        public void onAuthSucceed() {
            requestUserData();
        }

        //@Override
        public void onAuthFail(String error) {
            mText.setText("Login Failed: " + error);
        }
    }

    /*
     * The Callback for notifying the application when log out starts and
     * finishes.
     */
    public class FbAPIsLogoutListener implements LogoutListener {
        //@Override
        public void onLogoutBegin() {
            mText.setText("Logging out...");
        }

        ///@Override
        public void onLogoutFinish() {
            mText.setText("You have logged out! ");
            mUserPic.setImageBitmap(null);
        }
    }

On emulator it works perfect. 在模拟器上它完美无缺。 I have tried in ton 3 devices, that have already facebook installed and here is the problem. 我已尝试过已安装facebook的第3批设备,这就是问题所在。

it just spinning aroun on loading and it does nothing. 它只是在装载时旋转,它什么也没做。 I see the login button again. 我再次看到登录按钮。 Then i tried to logout from the original facebook application, and when pressing the login button on my app, i see the login window but now that I used to see when logging in the emulator but the login window of the original facebook application. 然后我尝试从原始的facebook应用程序注销,当我按下我的应用程序上的登录按钮时,我看到登录窗口,但现在我曾经看到登录模拟器但登录原始facebook应用程序的登录窗口。 Like is has started this one. 就像是已经开始这一个。

the code I am using is taken from the hackbook.java 我使用的代码来自hackbook.java

The Platform Status says that there's a problem with the SSO. 平台状态表明SSO存在问题。

The SSO only works if you have the facebook application installed on the android device, and what you describe fits right into all of this. 只有在Android设备上安装了facebook应用程序时才能使用SSO,并且您所描述的内容适合所有这些。 On the emulator you don't have the facebook application, and so when your application tries to log the user in it uses the dialog it has in the sdk instead of using the SSO process that ships with the fb application. 在模拟器上,您没有facebook应用程序,因此当您的应用程序尝试在其中记录用户时,使用它在sdk中的对话框,而不是使用fb应用程序附带的SSO进程。

On the device how ever you said that you do have the fb app, and so the SSO kicks in and, at least currently, there's a problem with it. 在设备上你怎么说你有fb应用程序,所以SSO开始,至少目前,它有一个问题。 Try to uninstall the facebook application on the device or maybe just cancel the SSO, ie: How to disable Facebook single sign on for android - Facebook-android-sdk 尝试卸载设备上的Facebook应用程序或者只是取消SSO,即: 如何禁用Facebook单点登录为Android - Facebook-android-sdk

您需要生成系统的哈希键,并通过编辑现有的Facebook应用程序来放置它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM