Android浏览器:打开几个网址,每一个新的窗口/标签(编程)几个、浏览器、窗口、标签

2023-09-06 07:25:13 作者:旧街里的酒

我知道如何使用意图打开网址:

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???

尝试创建若干意图和不同的startActivity每次打开,但它只是打开列表中的最后一个;

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 :)).

鸭preciate任何帮助!

Appreciate any help!

更新:仍然在寻找一个答案:/

UPDATE: still looking for an answer :/

我想出一个可行的解决方案,这的确会打开一个新窗口的URL。

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

莫名其妙任何方式启动活动可一次打开几个网址吗?东西的setResult()及startActivityForResult()可能?

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

推荐答案

我想出一个可行的解决方案,这的确会打开网址在新窗口中。

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);

反正不知怎么开始的活动可以一次打开几个网址吗?东西的setResult()及startActivityForResult()可能?

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