Skip to content Skip to sidebar Skip to footer

How To Stop Multiple Tabs Opened In Browser

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

Solution 1:

Use http://developer.android.com/reference/android/provider/Browser.html#EXTRA_APPLICATION_ID to ensure that the same browser tab is reused for your application. For example:Contextcontext= widget.getContext();
Intentintent=newIntent(Intent.ACTION_VIEW, uri);
intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());

You could also specify the Intent.FLAG_ACTIVITY_CLEAR_TASK flag to your intent to open a browser. This will clear any currently open tabs.

Solution 2:

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.

Post a Comment for "How To Stop Multiple Tabs Opened In Browser"