我知道如何使用 Intents 打开 URL:
Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.lala.com"));
startActivity(browserIntent);
但是我如何打开多个 URL,每个都在新窗口/标签上???
尝试创建多个 Intent 并使用不同的 startActivity 打开每个 Intent,但它只会打开列表中的最后一个;
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);
有什么方法可以启动 Activity 来一次打开多个 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);
关于Android 浏览器 : open several URLs, 每个在新窗口/选项卡上(以编程方式),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4119084/