gpt4 book ai didi

Android 应用程序在 FragmentActivity.java android.support.v4.app.FragmentActivity.startActivityForResult 上崩溃

转载 作者:行者123 更新时间:2023-12-03 05:02:23 24 4
gpt4 key购买 nike

在我的应用程序中,它们不是 FragmentActivity.java,但崩溃报告给了我以下错误

Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.google.android.gms&pcampaignid=gcore_8487000--- flg=0x80000 pkg=com.android.vending }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1647)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
at android.app.Activity.startActivityForResult(Activity.java:3415)
at android.app.Activity.startActivityForResult(Activity.java:3376)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784)
at android.app.Activity.startActivity(Activity.java:3611)
at android.app.Activity.startActivity(Activity.java:3579)
at com.google.android.gms.dynamic.zza$5.onClick(Unknown Source)
at android.view.View.performClick(View.java:4204)
at android.view.View$PerformClick.run(View.java:17373)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5056)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:840)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(NativeStart.java)

我不知道问题到底是什么、出在哪里,而且大多数时候这种崩溃发生在红米手机上

最佳答案

如果设备未安装 google play(没有 Activity 来处理此 intent),则会发生异常 - 您可以尝试在浏览器中打开网址 在这种情况下:

您可以使用google play包名称:com.android.vending

String pakcage_name="com.android.vending";

public static void open_google_play(Context context) {
try {
//open in play store app directly
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + pakcage_name)));
} catch (android.content.ActivityNotFoundException e) {
//open in browser
openBrowser(context, "https://play.google.com/store/apps/details?id=" + pakcage_name);
}
}

public static void openBrowser(Context context, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
if (null != intent.resolveActivity(context.getPackageManager())) {
context.startActivity(intent);
}
}

按钮单击期间使用它,编写此方法:

open_google_play(Activity.this);

关于Android 应用程序在 FragmentActivity.java android.support.v4.app.FragmentActivity.startActivityForResult 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41950805/

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