Android的Facebook的API的单点登录? [英] Android Facebook API single sign-on?

查看:153
本文介绍了Android的Facebook的API的单点登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于Android的Facebook的API单一登入()方法的问题。

在code以下使用包com.facebook.katana和阶级com.facebook.katana.proxyAuth。

问题是我没有这样的包和类在我的Eclipse安装,但似乎它使用的包和类的工作正常的活动 - 即使我没有之一。为什么呢?

  activity.startActivityForResult(意向,活动code);

不抛出 ActivityNotFoundException 即使我没有合适的包?误差

在code是在这里:

 私人布尔startSingleSignOn(活动活动,字符串的applicationID,
                                  的String []的权限,INT活动code){
    布尔didSucceed = TRUE;< BR>
    意向意图=新的Intent();    intent.setClassName(com.facebook.katana
            com.facebook.katana.ProxyAuth);
    intent.putExtra(CLIENT_ID的applicationID);
    如果(permissions.length大于0){
        intent.putExtra(范围,TextUtils.join(,权限));
    }    //验证应用程序的包名
    // com.facebook.katana.ProxyAuth已预期
    // Facebook应用程序签名。
    如果(!validateAppSignatureForIntent(活动,意图)){
        Log.d(脸谱 - startSignleSignOn,AppSign验证失败,返回didsucced假);
        返回false;
    }    mAuthActivity =活动;
    mAuthPermissions =权限;
    mAuthActivity code =活动code;
    尝试{
        activity.startActivityForResult(意向,活动code);
    }赶上(ActivityNotFoundException E){
        Log.d(Facebok的 - startSingleSignOn,活动未发现异常,回报didsucced假);
        didSucceed = FALSE;
    }    返回didSucceed;
}


解决方案

没关系。我发现在code自动使用的WebView Facebook的授权时,
他们无法找到com.facebook.katana套餐和com.facebook.katana.ProxyAuth级。

我相信那些包和类都包含在Facebook应用程序。所以,如果我有Facebook的官方应用,其中包括com.facebook.katana.ProxyAuth我的应用程序使用SigleSignOn方法使跳过我的应用程序的Facebook验证,如果用户登录到Facebook的正式申请。如果我没有Facebook的官方应用程序,那么应用程序使用传统的WebView及认证。

I have a question about the Android Facebook API singleSignOn() method.

The code below uses package "com.facebook.katana" and class "com.facebook.katana.proxyAuth".

The problem is I don't have such a package and class in my installation of Eclipse, but it seems the activity which uses those package and class works fine - even if I don't have one. Why?

The line

activity.startActivityForResult(intent, activityCode);

does not throw ActivityNotFoundException errors even if I don't have a right package?

The code is here:

private boolean startSingleSignOn(Activity activity, String applicationId,
                                  String[] permissions, int activityCode) {
    boolean didSucceed = true;<br>
    Intent intent = new Intent();

    intent.setClassName("com.facebook.katana",
            "com.facebook.katana.ProxyAuth");
    intent.putExtra("client_id", applicationId);
    if (permissions.length > 0) {
        intent.putExtra("scope", TextUtils.join(",", permissions));
    }

    // Verify that the application whose package name is
    // com.facebook.katana.ProxyAuth has the expected 
    // Facebook app signature.
    if (!validateAppSignatureForIntent(activity, intent)) {
        Log.d("Facebook - startSignleSignOn", "AppSign Validation Failed, return didsucced false");
        return false;
    }

    mAuthActivity = activity;
    mAuthPermissions = permissions;
    mAuthActivityCode = activityCode;
    try {
        activity.startActivityForResult(intent, activityCode);
    } catch (ActivityNotFoundException e) {
        Log.d("Facebok - startSingleSignOn", "Activity not found exception, return didsucced false");
        didSucceed = false;
    }

    return didSucceed;
}

解决方案

Never mind. I found out that the code automatically use webview Facebook authorization when they can not find "com.facebook.katana" package and "com.facebook.katana.ProxyAuth" class.

I believe those packages and classes are included in the Facebook application. So, if I have the Facebook official application which includes "com.facebook.katana.ProxyAuth", my application uses the SigleSignOn method which enables skipping the Facebook authentication of my app if the user logged on to the Facebook official application. And if I don't have the Facebook offical app, then the app uses traditional webview athentication.

这篇关于Android的Facebook的API的单点登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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