gpt4 book ai didi

Android - 打开 FB native 应用程序时找不到处理 Intent 的 Activity

转载 作者:太空狗 更新时间:2023-10-29 16:12:34 24 4
gpt4 key购买 nike

我正在尝试通过通知中收到的 url 在特定帖子上打开 FB 应用程序。

它在大多数设备上运行良好,但在 Samsung S7 上主要崩溃。我的简单代码:

String url = "fb://post/<post_id>";
Uri target = Uri.parse(url);
notifIntent = new Intent(Intent.ACTION_VIEW, target);
startActivity(notifIntent);

我之前检查过设备上是否存在 FB:

PackageManager packageManager = context.getPackageManager();
try {
int versionCode = packageManager.getPackageInfo("com.facebook.katana", 0).versionCode;
return "fb://post/" + fb_url;
} catch (PackageManager.NameNotFoundException e) {
return "https://www.facebook.com/" + fb_url; //normal web mUrl
}

错误日志:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{snip.snipnotifier/snip.snipnotifier.LoadingActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=fb://post/<post_id> }
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3149)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=fb://post/251996958535784_295668917501921 }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1817)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1515)
at android.app.Activity.startActivityForResult(Activity.java:4076)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
at android.app.Activity.startActivityForResult(Activity.java:4023)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:856)
at android.app.Activity.startActivity(Activity.java:4347)
at android.app.Activity.startActivity(Activity.java:4315)
at snip.snipnotifier.LoadingActivity.onCreate(LoadingActivity.java:29)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

感谢您的帮助。

最佳答案

因为在 Samsung S7 中没有 Activity 来处理你的 Intent 。你已经通过这个先检查了它。

if (sendIntent.resolveActivity(getPackageManager()) != null) {
startActivity(sendIntent);
}

希望这对您有所帮助。祝您编码愉快。

关于Android - 打开 FB native 应用程序时找不到处理 Intent 的 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41548209/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com