我想使用 facebook loginbutton 但不知为何它是自动登录的,我想让它自动注销然后用户按下它然后登录过程开始,我知道它是自动登录的因为我在我的 android 中登录Facebook 应用程序。
代码/h3>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.facebook.widget.LoginButton
android:id="@+id/authButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
/>
</LinearLayout>
最佳答案
实际上,如果我没有正确理解这个问题,您想要的是与 MuhammadAamirALi 发布的相反的内容。应该是这样的:
在 OnCreate 方法中:
Session activeSession = Session.getActiveSession();
//Checks for an open session
if (!(activeSession == null || activeSession.getState().isClosed())) {
//if found one, kill it.
activeSession.closeAndClearTokenInformation();
}
LoginButton authButton = (LoginButton) layout.findViewById(R.id.authButton);
authButton.setReadPermissions(Arrays.asList("basic_info", "email"));
如果有人知道实现相同目标的更好方法,我非常想知道(因为我现在正面临这个问题)。比如,如何防止 Facebook 在创建按钮时检查打开的 session 。
关于android facebook loginbutton自动登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17944582/