开发者

Android Browser: open several URLs, each on new window/tab (programmatically)

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

A开发者_JAVA百科ny 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);


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜