Session.openActiveSession只要求在开幕Facebook的Android SDK中 [英] Session.openActiveSession only calls OPENING in Facebook Android SDK
问题描述
我试图登录与Facebook使用Facebook的Android SDK,但是状态回调与打开
会话状态触发一次。在此之后,Facebook的登录活动似乎没有内容(我知道这是该活动,因为它有一个我为 title_facebook_login
设置在strings.xml中的标题)作一简要片刻,在一秒钟内消失。没有其他的回调被触发,没有例外,没有崩溃。它只是等待永远在我最初的活动。这是我的code:
I am trying to login with Facebook using the Facebook Android SDK, however, the status callback is fired only once with OPENING
session state. After that, a Facebook login activity appears with no content (I know it's that activity as it has the title that I've set for title_facebook_login
in strings.xml) for a brief moment and disappears within a second. No other callback is fired, no exceptions, no crashes. It just waits forever at my initial activity. Here is my code:
Session.openActiveSession(parent, true, new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if(state == SessionState.OPENED){
String accessToken = session.getAccessToken();
}
}
});
为什么不回调火 SessionState.OPENED
(或创建的,甚至是封闭式的),但只打开了?
Why wouldn't the callback fire for SessionState.OPENED
(or CREATED, or even CLOSED) but only OPENING?
推荐答案
您需要调用 onActivityResult
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data);
}
所以,当登录完成。它涉及到同样的活动,并呼吁状态回调是会话状态打开
初始化 UiLifecycleHelper
private UiLifecycleHelper uiHelper;
在OnCreate中需要之前调用的setContentView
in oncreate need to call before setContentView
uiHelper = new UiLifecycleHelper(this, statusCallback);
uiHelper.onCreate(savedInstanceState);
和需要保持会议
@Override
protected void onResume() {
super.onResume();
uiHelper.onResume();
}
@Override
protected void onPause() {
super.onPause();
uiHelper.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
uiHelper.onDestroy();
}
这篇关于Session.openActiveSession只要求在开幕Facebook的Android SDK中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!