如何通过Android中的代码打开内置的Web浏览器?

发布于 2025-01-31 11:18:34 字数 765 浏览 1 评论 0原文

简而言之,我已经使用了代码在这里在Android内置的Web浏览器中打开一个URL。

但是,由于我需要打开许多不同的URL,因此我想为每个URL打开并关闭浏览器(而不是打开选项卡)。

打开浏览器的代码:

try {
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(download_link));
startActivity(myIntent);
 } catch (ActivityNotFoundException e) {
    Toast.makeText(this, "No application can handle this request."
    + " Please install a webbrowser",  Toast.LENGTH_LONG).show();
    e.printStackTrace();
  }

我的意思是我的应用程序可以打开浏览器,并给出URL加载网站。但是,如果我给出另一个URL,它将作为同一打开的浏览器上的新标签打开。我不需要这个,尤其是当我想运行数千个URL时。我想使用我的应用打开浏览器并将其关闭。是否可以? 谁能帮我吗?

Simply, I have used the code here to open a URL in the Android's built-in web browser.

However, because I need to open many different URLs, I want to open and close the browser for every URL (instead of opening tabs).

Code for open a browser:

try {
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(download_link));
startActivity(myIntent);
 } catch (ActivityNotFoundException e) {
    Toast.makeText(this, "No application can handle this request."
    + " Please install a webbrowser",  Toast.LENGTH_LONG).show();
    e.printStackTrace();
  }

I mean that my app can open a browser, and give the URL to load the website. However, if I give another URL, it will open as a new tab on the same opened browser. I do not need this especially when I want to run thousands of URLs. I want to open the browser and close it for every URL using my app. Is it possible?
Can anyone help me with this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文