Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android浏览器:打开几个URL,每个URL位于新窗口/选项卡上(以编程方式)_Android_Android Intent_Android Browser - Fatal编程技术网

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

Android浏览器:打开几个URL,每个URL位于新窗口/选项卡上(以编程方式),android,android-intent,android-browser,Android,Android Intent,Android Browser,我知道如何使用意图打开URL: Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.lala.com")); startActivity(browserIntent); 但我如何打开多个URL,每个URL都在新窗口/选项卡上 尝试创建几个意图,并以不同的startActivity打开每个意图,但它只打开列表中的最后一个意图 code code code startActivi

我知道如何使用意图打开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);
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);


有没有办法启动活动,一次打开几个URL?setResult()和startActivityForResult()可能有什么问题?

我想出了一个可能的解决方案,它确实可以在一个新窗口中打开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);
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);

不管怎么说,启动活动一次打开几个URL?setResult()和startActivityForResult()可能会出现问题?

这可能有点晚了,但有些人可能仍然觉得这很有用

根据,

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


因此,要回答您的问题,请在2
startActivity

@liorry:使用
WebView
编写您自己的浏览器。或者,考虑一下可用性,放弃你的计划。不能使用我自己的浏览器:\n你的意思是这完全不可能吗?既然WebView为你做了一切,那就不难做到了。但我承认,我想知道三个网页同时打开是否会是一种良好的用户体验。@Reuben,你能举个例子吗?我想在默认的系统浏览器中打开URL。顺便说一句,关于可用性,我觉得很奇怪,默认情况下我不能在一次点击中打开多个网站。每次我只打开一个书签时,Android浏览器就会关闭书签窗口,即使它设置为在后台的新窗口中打开。