如何通过Android中的代码打开内置的Web浏览器?
简而言之,我已经使用了代码在这里在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论