简体   繁体   English

Facebook使用对话框登录,而不是Android本机登录

[英]Facebook Log In Using Dialog and Not Native Log In Android

I have been searching for the approach on how to log in in facebook using web dialog. 我一直在寻找有关如何使用Web对话框登录Facebook的方法。 I am working with this so that the native facebook app[whenever it is installed in the device], will not be affected. 我正在使用此程序,以便本机Facebook应用程序(无论何时将其安装在设备中)都不会受到影响。 By the way, all I want to achieve is to log in using dialog using facebook sdk version 3. Thank you! 顺便说一句,我要实现的是使用使用对话框的sdk版本3登录对话框。谢谢!

With SDK 3.0, you need to do it via an OpenRequest, something like: 使用SDK 3.0,您需要通过OpenRequest进行操作,例如:

Session s = new Session(this);
Session.OpenRequest request = new Session.OpenRequest(this);
request.setCallback(new Session.StatusCallback() {...});
request.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO); // <-- this is the important line
s.openForRead(request);
Session.setActiveSession(s);

For this you need to set the property SessionLoginBehavior , If you are using the facebook login button as described by the tutorial , then you just have to set the property of login button like this: 为此,您需要设置属性SessionLoginBehavior ,如果您按照本教程的说明使用facebook登录按钮,则只需设置登录按钮的属性,如下所示:

loginButton.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO);

and if you are logging in with out fb login button then you can just set the property of OpenRequest object you should be providing to open the session. 如果您没有使用fb登录按钮登录,则只需设置应提供的OpenRequest对象的属性即可打开会话。

 openRequest.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO);

Look at this for other login behaviours. 查看其他登录行为。

Try this, 尝试这个,

mFacebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener());

It does not use your native app login for sure. 它肯定不会使用您的本机应用程序登录名。

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

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