Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android/Java: open a link in Chrome using a specific tab (not the last one)

Tags:

java

android

I know that I can use EXTRA_APPLICATION_ID so as not to make chrome always open a new tab, but this has an undesired effect: it will open the URL in the last used tab, which I don't want to.

My intention is this: open the URL in a new tab only for the first time and then always use that tab, independently of whether the user has been navigating to other tabs.

Why I want this: Because I'm getting the copied to clipboard text and I want that text to be searched at a specific URL. So if the user is in some news website and copied a word he wants to be searched for, chrome will be opened at the same tab he was, which is undesired.

Is there a way to achieve this?

like image 641
MirrorMirror Avatar asked Dec 13 '18 09:12

MirrorMirror


1 Answers

there's no way to do that (because never getting the index of the opened tab returned - and not being able to tell which tab one wants to remote; this does not work alike a Chrome extension).

but you could instead just use a WebView - which would provide the desired effect - despite never leaving the app; or even a WebView in an overlaid DialogFragment, instead of a new Activity.

like image 121
Martin Zeitler Avatar answered Nov 02 '22 05:11

Martin Zeitler