有时,当我尝试在应用程序中打开浏览器进行添加时,我的应用程序会崩溃,这是我的代码:
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
任何人都可以帮忙吗?