Facebook的登入,登出发行无效的密钥散列错误,而试图重新登录 [英] Facebook Login-Logout Issue Invalid Key Hash Error, While Trying to Login Again

查看:270
本文介绍了Facebook的登入,登出发行无效的密钥散列错误,而试图重新登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作的成功简单的Facebook登录,注销活动。

I have a simple Facebook login-logout activity that is working successfully.

然而,当我从应用程序注销我再次尝试登录,但Facebook的给无效密钥散列错误。

However, after I logout from the app I try to login again but the facebook gives invalid key hash error.

请注意,我登录和注销,在第一次成功但在我注销并尝试重新登录Facebook的给出了错误。应该怎么办?

Note that I login and logout at first time successfully but after I logged out and try to login again Facebook gives that error. What should be done?

感谢您的attenion。

Thanks for your attenion.

下面是我的code:

public class MainFragment extends Fragment {

private static final String TAG = MainFragment.class.getSimpleName();

private UiLifecycleHelper uiHelper;

private final List<String> permissions;

public MainFragment() {
    permissions = Arrays.asList("user_status");
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    uiHelper = new UiLifecycleHelper(getActivity(), callback);
    uiHelper.onCreate(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.activity_main, container, false);

    LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton);
    authButton.setFragment(this);
    authButton.setReadPermissions(permissions);

    return view;
}

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

    // For scenarios where the main activity is launched and user
    // session is not null, the session state change notification
    // may not be triggered. Trigger it if it's open/closed.
    Session session = Session.getActiveSession();
    if (session != null &&
           (session.isOpened() || session.isClosed()) ) {
        onSessionStateChange(session, session.getState(), null);
    }

    uiHelper.onResume();
}

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

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

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

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

private void onSessionStateChange(Session session, SessionState state,
        Exception exception) {
    if (state.isOpened()) {
        Log.i(TAG, "Logged in...");
    } else if (state.isClosed()) {
        if (Session.getActiveSession() != null) {
            Session.getActiveSession().closeAndClearTokenInformation();
        } 

        Session.setActiveSession(null);

        Log.i(TAG, "Logged out...");
    }
}

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

}

推荐答案

假设你已经添加了keyhash到您的Facebook应用程序。

Assuming that you already added the keyhash to your facebook application.

要确保在设置 - > Android系统。在类名称字段中输入第一个活动是与所有的包。 例: com.yourcompany.yourapp.MyFirstActivity

Be sure that in Setting -> Android. In the "Class Name" field your first activity is with all package. Example: com.yourcompany.yourapp.MyFirstActivity

这篇关于Facebook的登入,登出发行无效的密钥散列错误,而试图重新登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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