Android应用程序在同一选项卡中打开浏览器? [英] Android app opening browser in the same tab?

查看:125
本文介绍了Android应用程序在同一选项卡中打开浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现这很难解释,但我会尽力而为. 我有一个打开浏览器(firefox)的应用程序,并将该信息作为php变量从该应用程序发送到网页,我遇到的问题是我经常这样做,并且每次打开浏览器时都会打开一个新标签页

I'm finding this hard to explain, but i'll do my best. I have an app that opens the browser (firefox) and send information from that app to the webpage as a php variable, the problem i have is that i am doing this quite a lot, and everytime it opens the browser its opening a new tab.

我知道无法使用javascript等关闭标签页,因此有一种方法可以确保它始终打开到同一当前标签页中,这样我就不会一次打开多个标签.

I know there is no way to close a tab using javascript etc, so is there a way to ensure it always opens into the same current tab so i dont end up with several open at once.

每当应用启动浏览器时,我都不想继续关闭Firefox选项卡.

I dont want to keep having to close firefox tabs whenever the app fires up the browser.

对不起,如果很难理解. 谢谢.

Sorry if its hard to make sense of. Thanks.

推荐答案

可能有点晚了,但是我设法仅使用Chrome应用即可完成您想要的工作.

Probably this is a bit late, but I have managed to accomplish what you want only using Chrome app.

String url = "http://www.mypage.com";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.putExtra(Browser.EXTRA_APPLICATION_ID, "com.android.chrome");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);

这允许您重复使用Chrome上当前打开的标签,并将该标签中的当前URL更改为您在意图中提供的URL.

This allows you to re-use the current opened tab on Chrome and change the current URL in that tab to the one you are providing in the intent.

我也尝试过在Firefox上没有成功.

I also have tried with no success on Firefox.

我希望这会有所帮助.

这篇关于Android应用程序在同一选项卡中打开浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆