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

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

问题描述

我已经实现了Facebook登录和正常工作的一些设备/ AVDS。我的开发设备是姜饼手机,但用4.1.1设备测试它,它根本无法登录。pressing Facebook的按钮后,它显示了一个空白的屏幕(尝试连接Facebook的),经过1 2秒钟时间还是回到主屏幕。此外,没有错误烤或在logcat中显示。哦,和Facebook的应用程序安装在设备......任何想法?

更新:

我启用了日志记录所建议的马克Venzke和使用的过程中,我得到了这样的警告(两次)每登录尝试(注:用的HTC One的电话测试):

  07-05 20:14:50.582:W / PackageManager(605):无法加载服务信息ResolveInfo {4171dbf0 com.htc.socialnetwork.facebook.remote.FacebookSyncService P = 0 Ø= 0 M = 0x108000}
 

请注意该com.htc.socialnetwork.facebook.remote.FacebookSyncService线,所以有需要的HTC设备的任何额外的步骤?

另外,我也附加了code在这里进行登录:

 私人无效onSessionStateChange(会话的会话,SessionState会状态,例外的例外){
    如果(isResumed){
        FragmentManager经理= getSupportFragmentManager();
        INT backStackSize = manager.getBackStackEntryCount();
        的for(int i = 0; I< backStackSize;我++){
            manager.popBackStack();
        }
        com.facebook.Settings.addLoggingBehavior(LoggingBehavior.REQUESTS);
        如果(state.isOpened()){

            捆绑PARAMS =新包();
            params.putString(域,ID);
            params.putString(限制,1);
            请求请求=新的请求(Session.getActiveSession(),我,参数,可以HttpMethod.GET,新的回调()
            {

                @覆盖
                公共无效onCompleted(响应响应)
                {
                    如果(响应!= NULL)
                    {
                        Log.d(AuthGraphResponse,response.toString());
                        长ID;
                        尝试 {
                            ID = response.getGraphObject()getInnerJSONObject()getLong之(ID)。;
                            app.setFacebookId(ID);
                            Log.d(用户ID,Long.valueOf(ID)的ToString());
                        }赶上(JSONException E){
                            e.printStackTrace();
                        }
                    }
                }
            });

            RequestAsyncTask任务=新RequestAsyncTask(要求);
            task.execute();

            showFragment(AUTH,假);
        }否则如果(state.isClosed()){
            showFragment(未授权,FALSE);
        }
    }
}
 

更新2:

难道HTC重命名中的所有设备的默认的Facebook应用程序的包名(或其中的一部分,等等),以com.htc.socialnetwork.facebook(而不是com.facebook.katana),并导致这个矛盾呢?我真的不认为,卸载默认的应用程序,并从谷歌播放安装Facebook是一个可以接受的解决方案(也,我觉得默认的应用程序无法卸载)。

更新3:

没有解决呢。 19小时授予100美誉的赏金!

更新4:

在LogCat中的另一个有趣的路线:

  10月7号至15号:55:51.718:E /铬(30475):外部/铬/ NET / disk_cache / stat_hub.cc:216:0715/105551:ERROR:stat_hub .CC(216)] StatHub ::初始化 - 不支持应用程序com.facebook.katana。
 

解决方案

当然是有你的股票应用程序和SDK之间的冲突。所以,如果你不想uninnstall股票HTC应用程序,并仍使用SDK 3.0,我认为你最好的选择,而不modying的SDK源$ C ​​$ C将禁用SSO和密码只能通过web视图。

这可以很容易地通过添加SessionLoginBehavior.SU preSS_SSO每次试图打开一个新的会话完成。下面是一个示例我从SessionLoginSample(LoginUsingActivityActivity)从Facebook的SDK改为告诉你该怎么做:

  @覆盖
公共无效的onCreate(包savedInstanceState){
    ...
    会话会话= Session.getActiveSession();
    如果(会话== NULL){
        如果(savedInstanceState!= NULL){
            会议= Session.restoreSession(本,空,statusCallback,savedInstanceState);
        }
        如果(会话== NULL){
            会议=新的Session(本);
        }
        Session.setActiveSession(会议);

        //添加检查,因为如果会话被打开
        如果(session.getState()。等于(SessionState.CREATED_TOKEN_LOADED)||!session.getState()。isOpened()){
            //添加燮preSS SSO的行为给力的WebView身份验证对话框弹出
            session.openForRead(新Session.OpenRequest(this).setCallback(statusCallback).setLoginBehavior(SessionLoginBehavior.SUP$p$pSS_SSO));
        }
    }
  ...
}
//然后把你的code在statusCallback方法或保持在会话状态变化监听器
 

否则,如果你不介意改变了Facebook的SDK code,你应该检查这个的出

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?

UPDATE:

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}

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);
        }
    }
}

UPDATE 2:

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).

UPDATE 3:

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

UPDATE 4:

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.

解决方案

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.

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

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

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

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