如何停止在浏览器中打开的多个选项卡

问题描述:

我有一个Intent可以在Samsung平板电脑上的FireFox中打开网页,但每次都会保持打开新标签的状态.我一直在使用带有EXTRA_APPLICATION_ID的putExtra(),它以前曾做过花招,并使用相同的浏览器选项卡打开了页面,但现在它坏了.我不确定是否会有所不同,但是下面的代码是runOnUiThread(),因为还有其他处理会触及视图.任何想法将不胜感激.

I have an Intent that opens a web page in FireFox on a Samsung tablet but it keeps opening a new tab each time. I've been using the putExtra() with an EXTRA_APPLICATION_ID and it previously did the trick and opened the page reusing the same browser tab but now its broke. I'm not sure if it makes a difference but the code below is runOnUiThread() as there is other processing that touches views. Any ideas would be appreciated.

        String pageName = "http://google.com";

        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(pageName));
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, getApplication().getPackageName());

        startActivity(intent);

所以我注意到,当以上代码无法正常工作时,我的默认应用程序在Samsung pad上打开URL被设置为Samsung的Internet浏览器.我将默认设置切换为FireFox或Chrome,完全相同的代码再次可用!显然,Samsung Internet应用程序有些时髦,可以防止标签的重复使用.

So I noticed that when the above code did not work my default application to open a URL on the Samsung pad was set as Samsung's Internet browser. I switched the default to FireFox or Chrome and the exact same code works again! Apparently there is something funky about Samsung Internet app that prevents reuse of tabs.