从我的应用程序登录到Facebook在模拟器上工作,但不在设备上 [英] logging in to facebook from my app works on emulator but not on device

查看:145
本文介绍了从我的应用程序登录到Facebook在模拟器上工作,但不在设备上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我登录到Facebook的代码。

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

//如果存在$还原会话
SessionStore.restore(Utility.mFacebook,this);
SessionEvents.addAuthListener(new FbAPIsAuthListener());
SessionEvents.addLogoutListener(new FbAPIsLogoutListener());

/ *
*源代码:login_tag
* /
mLoginButton.init(这是AUTHORIZE_ACTIVITY_RESULT_CODE,Utility.mFacebook,权限);

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

// @覆盖
public void onAuthSucceed(){
requestUserData();
}

// @覆盖
public void onAuthFail(String error){
mText.setText(登录失败:+错误);
}
}

/ *
*退出时通知应用程序的回调,
*完成。
* /
public class FbAPIsLogoutListener实现LogoutListener {
// @覆盖
public void onLogoutBegin(){
mText.setText(Logging out ...) ;
}

/// @覆盖
public void onLogoutFinish(){
mText.setText(你已经注销!);
mUserPic.setImageBitmap(null);
}
}

在仿真器上,它工作完美。我已经尝试了3台设备,已经安装了Facebook,这里是问题。



它只是旋转aroun加载,它什么都不做。我再次看到登录按钮。
然后我试图从原始的Facebook应用程序注销,当按下我的应用程序的登录按钮时,我看到登录窗口,但现在我曾经看到登录模拟器,但原始Facebook的登录窗口应用。喜欢已经开始了这一个。



我使用的代码取自hackbook.java

解决方案

p>平台状态​​表示SSO有问题。



SSO仅在Android设备上安装了facebook应用程序,并且您所描述的适合所有这一切。
在模拟器上,您没有Facebook应用程序,因此当您的应用程序尝试在其中记录用户时,它使用sdk中具有的对话框,而不是使用fb应用程序附带的SSO进程。 / p>

在设备上你怎么说你有fb应用程序,所以SSO踢了,至少目前有一个问题。
尝试卸载设备上的Facebook应用程序,或者可能只是取消SSO,即:如何禁用Facebook单一登录Android - Facebook-android-sdk


This is my code for logging in to 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.

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. Like is has started this one.

the code I am using is taken from the hackbook.java

解决方案

The Platform Status says that there's a problem with the 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. 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.

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. Try to uninstall the facebook application on the device or maybe just cancel the SSO, i.e.: How to disable Facebook single sign on for android - Facebook-android-sdk

这篇关于从我的应用程序登录到Facebook在模拟器上工作,但不在设备上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆