Android 浏览器:打开多个 URL,每个 URL 都在新窗口/选项卡上(以编程方式)

发布于 2024-10-01 17:52:49 字数 1084 浏览 1 评论 0原文

我知道如何使用 Intents 打开 URL:

Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.lala.com"));
startActivity(browserIntent);

但是如何打开多个 URL,每个 URL 都在新窗口/选项卡上???

尝试创建多个意图并使用不同的 startActivity 打开每个意图,但它只打开列表中的最后一个;

code code code
startActivity(Intent1); startActivity(Intent2); startActivity(Intent3); -> only Intent3 is opened eventually (which of course make sense :)).

感谢任何帮助!

更新:仍在寻找答案:/

我已经提出了一个可能的解决方案,它确实在新窗口中打开了 URL。

Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.go.com"));
Bundle b = new Bundle();
b.putBoolean("new_window", true); //sets new window
intent.putExtras(b);
startActivity(intent);

BrowserBookmarksPage.java

有什么方法可以启动 Activity 来同时打开多个 URL? setResult() & 的东西也许是 startActivityForResult() ?

I know how to open a URL using Intents:

Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.lala.com"));
startActivity(browserIntent);

But how can I open multiple URLs, each on new window/tab???

Tried creating several Intents and opened each with different startActivity but it just opens the last one on the list;

code code code
startActivity(Intent1); startActivity(Intent2); startActivity(Intent3); -> only Intent3 is opened eventually (which of course make sense :)).

Appreciate any help!

UPDATE: still looking for an answer :/

I've come up with a possible solution, which indeed opens the URL in a new window.

Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.go.com"));
Bundle b = new Bundle();
b.putBoolean("new_window", true); //sets new window
intent.putExtras(b);
startActivity(intent);

BrowserBookmarksPage.java

Any way of somehow start the Activity to open several URLs at once? something with setResult() & startActivityForResult() maybe?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萝莉病 2024-10-08 17:52:49

我想出了一个可能的解决方案,它确实在新窗口中打开 URL。

Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.go.com"));
Bundle b = new Bundle();
b.putBoolean("new_window", true); //sets new window
intent.putExtras(b);
startActivity(intent);

I've come up with a possible solution, which indeed opens the URL in a new window.

Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.go.com"));
Bundle b = new Bundle();
b.putBoolean("new_window", true); //sets new window
intent.putExtras(b);
startActivity(intent);
冬天旳寂寞 2024-10-08 17:52:49

根据 此< /a>

第二个攻击向量利用 Android 浏览器正确处理意图所需的时间间隔。如果在足够短的时间间隔内发送两个意图,浏览器将在同一个选项卡中执行它们。第一个意图可能是打开目标域,第二个意图可能是执行恶意 JavaScript。

因此,要回答您的问题,请在 2 startActivity 之间设置一个小延迟。

According to this

The second attack vector exploits the interval of time the Android browser needs to process intents properly. If two intents are sent in a short enough interval of time, the browser will execute them in the same tab. The first intent can be to open the targeted domain and the second can be to execute rogue javascript.

So to answer your question, put a small delay in between 2 startActivity.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文