简体   繁体   English

Facebook Android SDK 3.0和Lollipop

[英]Facebook Android SDK 3.0 and Lollipop

I'm having a problem with an explicit Intent found in the Facebook SDK on Lollipop. 我对Lollipop上的Facebook SDK中的显式Intent有问题。 Before Api v21 this only supposedly raised an error but now it throws an exception. 在Api v21之前,这仅引发了错误,但现在它引发了异常。 I'm wondering if there is a fix to turn this into an implicit intent. 我想知道是否有解决方案可以将其转换为隐式意图。 The part which fails is this: 失败的部分是这样的:

Intent intent = new Intent(NativeProtocol.INTENT_ACTION_PLATFORM_SERVICE);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent = NativeProtocol.validateKatanaServiceIntent(context, intent);

    if (intent == null) {
        callback(null);
        return false;
    } else {
        running = true;
        context.bindService(intent, this, Context.BIND_AUTO_CREATE);
        return true;
    }

What I tried is to set the package name like: 我试着将包名称设置为:

intent.setPackage("com.facebook");

But that didnt work. 但这没有用。

Any ideas? 有任何想法吗?

thank you 谢谢

So I've found a way to it: 所以我找到了解决方法:

Intent intent = new Intent(NativeProtocol.INTENT_ACTION_PLATFORM_SERVICE);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent = NativeProtocol.validateKatanaServiceIntent(context, intent);
    ResolveInfo resolveInfo = context.getPackageManager().resolveService(intent, 0);
    if (intent == null) {
        callback(null);
        return false;
    } else {
        running = true;
        intent.setPackage(resolveInfo.serviceInfo.packageName);
        context.bindService(intent, this, Context.BIND_AUTO_CREATE);
        return true;
    }

If anyone else needed this. 如果还有其他人需要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM