Android Browser: open several URLs, each on new wi

2019-02-15 21:47发布

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?

2条回答
做个烂人
2楼-- · 2019-02-15 22:15

This may be little late, but some may still find this useful

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.

查看更多
Viruses.
3楼-- · 2019-02-15 22:20

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

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

查看更多
登录 后发表回答