【发布时间】:2020-11-04 02:27:56
【问题描述】:
我编写这段代码是为了从我在 android studio(google) 中的应用程序在浏览器中打开一个网站:
String google = "http://www.google.com";
Uri webAddress = Uri.parse(google);
Intent goToGoogle= new Intent(Intent.ACTION_VIEW, webAddress);
if(goToGoogle.resolveActivity(getPackageManager()) != null) {
startActivity(goToGoogle);
}
当我不放 if 语句时,该应用程序只会执行我希望它执行的操作,否则该按钮将不执行任何操作。这是为什么呢?
谢谢
【问题讨论】:
标签: java android-studio android-intent