简体   繁体   中英

Facebook Android SDK 3.0 and Lollipop

I'm having a problem with an explicit Intent found in the Facebook SDK on Lollipop. Before Api v21 this only supposedly raised an error but now it throws an exception. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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