Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Facebook android sdk 3.0登录问题_Android_Facebook Android Sdk - Fatal编程技术网

Facebook android sdk 3.0登录问题

Facebook android sdk 3.0登录问题,android,facebook-android-sdk,Android,Facebook Android Sdk,我最近升级了我的代码,使用FB android SDK 3.0。我的应用程序有四个活动,不使用片段。奇怪的是,我的代码在安卓2.3.4上运行没有任何问题。但在安卓4.0.4中,会话状态总是“打开”。我正在使用UiLifeCycleHelper,下面是启动程序活动中的代码 SharedPreferences mPrefs; String access_token = mPrefs.getString("access_token", null); Session currentSession =

我最近升级了我的代码,使用FB android SDK 3.0。我的应用程序有四个活动,不使用片段。奇怪的是,我的代码在安卓2.3.4上运行没有任何问题。但在安卓4.0.4中,会话状态总是“打开”。我正在使用UiLifeCycleHelper,下面是启动程序活动中的代码

SharedPreferences mPrefs;
String access_token = mPrefs.getString("access_token", null);

Session currentSession = Session.getActiveSession();
if(currentSession == null || currentSession.getState().isClosed())
{
    if(access_token!=null)
    {
        SharedPreferences.Editor editor = mPrefs.edit(); 

    //One time upgrade from FB SDK 2.0 to 3.0
        editor.putString("access_token", null);
        editor.commit();

        AccessToken new_access_token = AccessToken.createFromExistingAccessToken(access_token, null, null, null, null);
        currentSession.open(new_access_token, myCallback);
        Session.setActiveSession(currentSession);
    }
    else
    {
        Session.openActiveSession(this, true, myCallback);
    }
}
else if (!currentSession.isOpened())
{
     OpenRequest openRequest = new OpenRequest(this).setCallback(myCallback);
     openRequest.setDefaultAudience(SessionDefaultAudience.FRIENDS);
     openRequest.setPermissions(Arrays.asList(permissions));
     openRequest.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);
     currentSession.openForRead(openRequest);

}
else if(currentSession.isOpened())
{
    handleRequest(currentSession);

}


StatusCallback myCallback = new StatusCallback()
{

    @Override
    public void call(Session session, SessionState state, Exception exception)
    {
        handleRequest(session);

    }
};


public void handleRequest(Session activeSession)
{

    Request new_request = new Request(activeSession, "/me/friends", null, null, new Callback()
    {

        @Override
        public void onCompleted(Response response)
        {

            //Process the response and make UI changes.
        }

});
}
首先,我怀疑这个问题是由于一个旧版本的Facebook应用程序(1.9)造成的。所以我升级到了最新版本(3.2)。但问题仍然存在于android 4.0.4上

这是我在onActivityResult回调中的代码

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
        super.onActivityResult(requestCode, resultCode, data);
        Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
        uihelper.onActivityResult(requestCode, resultCode, data);
}

有什么问题吗?

您是否记得将
添加到ActivityResult
代码中

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

再看看

我自己解决的。刚刚在myCallback中注释掉HandlerRequest

StatusCallback myCallback = new StatusCallback()
{

    @Override
    public void call(Session session, SessionState state, Exception exception)
    {
    //handleRequest(session);

    }
};

这次我的应用程序在安卓2.3.4和4.0.4上都可以正常工作

请看我的编辑。我把你提到的问题都看了一遍。我正在使用ListActivity而不是Activity。这是个问题吗?