某些设备上的Facebook登录失败 [英] Facebook login fails on some devices

查看:437
本文介绍了某些设备上的Facebook登录失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实施了Facebook登录,在某些设备/ AVD上可以正常工作。我的开发设备是Gingerbread手机,但是使用4.1.1设备进行测试,它根本不会登录。按下Facebook按钮后,显示一个空白屏幕(尝试连接Facebook),1-2秒后回到主屏幕。此外,Logcat中没有任何错误被烘烤或显示。哦,Facebook应用程序安装在设备中...任何想法?

I have implemented the Facebook login and it works fine on some devices/AVDs. My development device is a Gingerbread phone, but testing it with a 4.1.1 device, it simply does not log in. After pressing the facebook button, it shows a blank screen (trying to connect Facebook), and after 1-2 seconds it comes back to the home screen. Also, no errors are toasted or displayed in the Logcat. Oh, and the Facebook application is installed in the device... Any ideas?

更新:

我按照Mark Venzke的建议启用了日志记录,并使用过程,并收到此警告(两次)(注意:使用HTC One S手机进行测试):

I enabled logging as suggested by Mark Venzke and using this procedure, and I got this warning (twice) on every login attempt (note: testing with a HTC One S phone):

07-05 20:14:50.582: W/PackageManager(605): Unable to load service info ResolveInfo{4171dbf0 com.htc.socialnetwork.facebook.remote.FacebookSyncService p=0 o=0 m=0x108000}

注意com.htc.socialnetwork.facebook.remote.FacebookSyncService行,HTC设备需要额外的步骤吗?

Note the com.htc.socialnetwork.facebook.remote.FacebookSyncService line, so is there any extra step needed for HTC devices?

另外,我附加执行登录的代码:

Also, I'm attaching the code where the login is performed:

private void onSessionStateChange(Session session, SessionState state, Exception exception) {
    if (isResumed) {
        FragmentManager manager = getSupportFragmentManager();
        int backStackSize = manager.getBackStackEntryCount();
        for (int i = 0; i < backStackSize; i++) {
            manager.popBackStack();
        }
        com.facebook.Settings.addLoggingBehavior(LoggingBehavior.REQUESTS);
        if (state.isOpened()) {

            Bundle params = new Bundle();
            params.putString("fields", "id");
            params.putString("limit", "1");             
            Request request = new Request(Session.getActiveSession(), "me", params, HttpMethod.GET, new Callback()
            {

                @Override
                public void onCompleted(Response response)
                {
                    if (response != null)
                    {
                        Log.d("AuthGraphResponse", response.toString());
                        long id;
                        try {
                            id = response.getGraphObject().getInnerJSONObject().getLong("id");
                            app.setFacebookId(id);
                            Log.d("UserID", Long.valueOf(id).toString());
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }
            });

            RequestAsyncTask task = new RequestAsyncTask(request);
            task.execute();

            showFragment(AUTH, false);
        } else if (state.isClosed()) {
            showFragment(UNAUTH, false);
        }
    }
}

更新2:

HTC是否可以在com.htc的所有设备(或其中一些,无论什么)中重命名默认Facebook应用程序的包名称。 socialnetwork.facebook(而不是com.facebook.katana),它会导致这种冲突?我不认为卸载默认应用程序并从Google Play安装Facebook是一个可以接受的解决方案(我也认为默认应用程序无法卸载)。

Is it possible that HTC renames the package name of the default Facebook application in all the devices (or some of them, whatever) to com.htc.socialnetwork.facebook (instead of com.facebook.katana) and it leads to this conflict? I don't really think that uninstalling the default app and installing Facebook from Google Play is an acceptable solution (also, I think default apps cannot be uninstalled).

更新3:

尚未解决。 19个小时给100个声誉赏金!

Not solved yet. 19 hours to award the 100 reputation bounty!

更新4:

另一个LogCat的有趣的一行:

Another interesting line of the LogCat:

07-15 10:55:51.718: E/chromium(30475): external/chromium/net/disk_cache/stat_hub.cc:216: [0715/105551:ERROR:stat_hub.cc(216)] StatHub::Init - App com.facebook.katana isn't supported.


推荐答案

您的股票应用程序与SDK。所以,如果你不想uninsstall股票HTC应用程序,仍然使用SDK 3.0我认为你最好的打赌,而不修改sdk的源代码将是禁用SSO和登录只能通过webview。

There is certainly a conflict between your stock app and the SDK. So if you don't want to uninnstall the stock HTC app and still use the SDK 3.0 I think your best bet without modying the source code of the sdk would be to disable SSO and login only through webview.

每次尝试打开新会话时,可以通过添加SessionLoginBehavior.SUPRESS_SSO轻松完成此操作。以下是从Facebook SDK中的SessionLoginSample(LoginUsingActivityActivity)中更改的示例,以显示如何处理:

This can easily be done by adding the SessionLoginBehavior.SUPRESS_SSO everytime you try to open a new session. Here is a sample I changed from the SessionLoginSample (LoginUsingActivityActivity) from the Facebook SDK to show you what to do :

@Override
public void onCreate(Bundle savedInstanceState) {
    ...
    Session session = Session.getActiveSession();
    if (session == null) {
        if (savedInstanceState != null) {
            session = Session.restoreSession(this, null, statusCallback, savedInstanceState);
        }
        if (session == null) {
            session = new Session(this);
        }
        Session.setActiveSession(session);

        //add the check, for if session is opened
        if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED) || !session.getState().isOpened()) {
            //Add the suppress SSO behavior to force webview auth dialog to popup
            session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback).setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO));
        }
    }
  ...
}
//then put your code in the statusCallback method or keep it in the session state change listener

否则,如果您不介意更改Facebook sdk代码,您应该检查这个出来

Otherwise if you don't mind changing the facebook sdk code, you should check this out

这篇关于某些设备上的Facebook登录失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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