[英]Facebook Android SDK 3.0 and Lollipop
我對Lollipop上的Facebook SDK中的顯式Intent有問題。 在Api v21之前,這僅引發了錯誤,但現在它引發了異常。 我想知道是否有解決方案可以將其轉換為隱式意圖。 失敗的部分是這樣的:
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;
}
我試着將包名稱設置為:
intent.setPackage("com.facebook");
但這沒有用。
有任何想法嗎?
謝謝
所以我找到了解決方法:
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;
}
如果還有其他人需要。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.