登录后,Facebook的seession关闭过程中的Andr​​oid [英] Facebook seession is closed after log in process in Android

查看:127
本文介绍了登录后,Facebook的seession关闭过程中的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Android应用程序需要的Facebook登录信息发布Facebook的意见。但是我就死在登录的,所以我也跟着教程在的https://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrumptious/authenticate/但我发现state.isCloced()==真登录后(Facebook的登录按钮也不会改变它的文本注销)。我看不出有任何理由,为什么它不工作。谁能帮我?

I'm developing android app which require facebook login for posting facebook comments. However I've got stuck on logging in. So I followed tutorial at https://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrumptious/authenticate/ but I'm getting state.isCloced() == true after log in (facebook login button also does not change it's text to log out). I don't see any reason why it is not working. Can anyone help me?

到的定做教程中,我有片段:

Reffering to tutorial I have fragment:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
<com.facebook.widget.LoginButton
    android:id="@+id/login_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_marginBottom="30dp"
    android:layout_marginTop="30dp" />
</LinearLayout>

和我MainActivity:

And in my MainActivity:

    private UiLifecycleHelper uiHelper;
private Session.StatusCallback callback = new Session.StatusCallback() {
    @Override
    public void call(Session session, SessionState state, Exception exception)                 {
        onSessionStateChange(session, state, exception);
    }
};

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
}



private void onSessionStateChange(Session session, SessionState state, Exception exception) {
    if (state.isOpened()) {
        Log.i("FacebookFragment", "State is opened");
    } else if (state.isClosed()) {
        Log.i("FacebookFragment", "State is closed");
    }
}

@Override
public void onResume() {
    super.onResume();
    uiHelper.onResume();
}

@Override
public void onPause() {
    super.onPause();
    uiHelper.onPause();
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    uiHelper.onActivityResult(requestCode, resultCode, data);
}

@Override
public void onDestroy() {
    super.onDestroy();
    uiHelper.onDestroy();
}

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    uiHelper.onSaveInstanceState(outState);
}

在我点击LoginButton,FB权限对话框弹出时,我点击确定,然后我看到全面进步吧,然后我再次看到登录按钮。在LogCat中仍是国家关闭:(

After I click LoginButton, fb permission dialog pops up, I click ok, then I see round progress bar and then I see login button again. In LogCat is still State is closed :(

我是不是做错了什么?或可能是因为被嵌套在另一个片段,片段与loginButton?

Am I doing something wrong? Or could it be because Fragment with loginButton is nested in another fragment?

我测试的设备与Android 4,本机FB应用程序安装。

I'm testing on device with android 4, native FB app installed.

感谢:)

推荐答案

好吧,我解决了这个问题,根据remote_app_id不匹配存储的ID例外,我找到答案的http://stackoverflow.com/a/14421260/1618316 和印刷的Facebook应用程序ID。首先,我生成应用程序ID与FB教程的命令,但它是不同的一个由上面的回答打印。所以,我提出了新的关键在FB,现在它的作品。

Ok I solved it, based on "remote_app_id does not match stored id" exception i found answer http://stackoverflow.com/a/14421260/1618316 and printed facebook app id. First I generated app id with command from fb tutorial, but it was different to one printed by answer above. So I put new key at fb and now it works.

不过,我仍然不知道如何可能从教程命令给了我错了哈希:/

But I still wonder how is possible that command from tutorial gave me wrong hash :/

这篇关于登录后,Facebook的seession关闭过程中的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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