gpt4 book ai didi

android - 打开浏览器时出现 ActivityNotFoundException

转载 作者:行者123 更新时间:2023-11-30 04:07:29 28 4
gpt4 key购买 nike

有时,当我尝试在应用程序中打开浏览器进行添加时,我的应用程序会崩溃,这是我的代码:

public void onBannerClick(final View view){  
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(mBannerURL));
startActivity(intent);

这是我得到的堆栈跟踪:

java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:2179)
at android.view.View.performClick(View.java:2535)
at android.view.View$PerformClick.run(View.java:9130)
at android.os.Handler.handleCallback(Handler.java:618)
at android.os.Handler.dispatchMessage(Handler.java:123)
at android.os.Looper.loop(SourceFile:351)
at android.app.ActivityThread.main(ActivityThread.java:3850)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:538)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:659)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:538)
at android.view.View$1.onClick(View.java:2174)
... 11 more
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://xxxxxxxxx.xx }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1449)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1419)
at android.app.Activity.startActivityForResult(Activity.java:2878)
at android.app.Activity.startActivity(Activity.java:2984)
at com.XXXXXXXXX.XXXXXXXXXXXXX.MainActivity.onBannerClick(MainActivity.java:830)
... 14 more

任何人都可以帮忙吗?

最佳答案

检查您的方案是否拼写正确。我发现仅仅使用“HTTP:”而不是“http:”就导致了这个问题。此页底部的注释:

http://developer.android.com/guide/topics/manifest/data-element.html

...Android 中的方案匹配区分大小写。

关于android - 打开浏览器时出现 ActivityNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11377488/

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