简体   繁体   English

安装FB应用程序时,Android Facebook示例应用程序无法登录

[英]Android Facebook sample app doesn't login when FB app installed

At first I thought this was my app but I get the exact same problem when using any of the FB sample apps. 起初我认为这是我的应用程序,但在使用任何FB示例应用程序时,我得到完全相同的问题。

Take the HelloFacebookSample for example, which gives you a login button and after login shows you your pic and enables you to post status updates. 以HelloFacebookSample为例,它为您提供了一个登录按钮,登录后会显示您的图片并允许您发布状态更新。

If I don't have the FB app installed on my phone the login button gives me a web view which i login through and the photo appears in the app and i can make posts. 如果我没有在我的手机上安装FB应用程序,登录按钮会给我一个网页视图,我登录并且照片出现在应用程序中,我可以发帖。 However if the FB app is installed on my phone it brings up a dialog saying the app would like to access you public profile etc. I press OK and..... nothing. 但是,如果我的手机上安装了FB应用程序,它会弹出一个对话框,说应用程序想要访问您的公开个人资料等。我按OK和.....没有。

I have found many questions that seem similar but the problem was usually using a debug key as opposed to a release key, but I am running from eclipse so the debug key is still appropriate. 我发现很多看似相似的问题,但问题通常是使用调试密钥而不是发布密钥,但是我从eclipse运行,所以调试密钥仍然合适。

Any ideas? 有任何想法吗?

if there is the default Facebook App is installed in your phone or if you are trying to upload your app on Google Play, then you need a different KeyHash. 如果手机中安装了默认的Facebook应用程序,或者您尝试在Google Play上上传应用程序,那么您需要一个不同的KeyHash。 because, when u developed your FB app you have registered your FB app with a key hash which is created by using the default debug.keystore. 因为,当你开发你的FB应用程序时,你已经使用默认的debug.keystore创建的密钥哈希注册了你的FB应用程序。

so, now u need a different KeyStore to generate the different KeyHash. 所以,现在你需要一个不同的KeyStore来生成不同的KeyHash。 u need a signed KeyStore, which u can get by the help of this tutorial , after generating new keystore, generate a key hash and register your FB App with this new key hash. 你需要一个签名的KeyStore,你可以在生成新的密钥库之后通过本教程的帮助获得,生成一个密钥哈希并用这个新的密钥哈希注册你的FB应用程序。 this should work. 这应该工作。 for generating new KeyHash u can follow this link 用于生成新的KeyHash你可以点击此链接

I found the next line that helped me in the above scenario: 在上面的场景中,我找到了帮助我的下一行:

mLoginFacebook.setReadPermissions(Arrays.asList("email"));

it comes right after: 它紧随其后:

mLoginFacebook = (LoginButton) rootView.findViewById(R.id.authButton);
mLoginFacebook.setFragment(this);

solved all my problems.. Cheers 解决了我所有的问题..干杯

I would try and follow this tutorial to see if you can get a sample app that you build yourself to connect with Facebook. 我会尝试按照本教程查看您是否可以获得自己构建的示例应用程序以连接Facebook。 I had issues connecting the sample apps with Facebook as well. 我也有将问题应用程序与Facebook连接的问题。 I would also check that your app id from Facebook is in your manifest file. 我还会检查您的Facebook应用ID是否在您的清单文件中。

https://developers.facebook.com/docs/howtos/androidsdk/3.0/login-with-facebook/ https://developers.facebook.com/docs/howtos/androidsdk/3.0/login-with-facebook/

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

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