How to get URL and selection text from Android browser with the intention to share

In new versions of Android phones (definitely starting with ICS, probably already at 2.3.5, at least on HTC EVO), when you make a selection in the browser, it shows a pop-up window with three dots, clicking on which opens the menu, which offers options for copying, sharing, etc. If you choose sharing, you can choose to share it.

For the application I'm working on, I need both the selected text and the URL of the page from which it came when the user shares with my application.

In HTC EVO 2.3.5, this provides both the page URL and the selected text. However, on other phones we get only selected text. Therefore, I suspect that getting both on HTC EVO was a carrier / manufacturer reinforcement. For this phone, the highlighted text appears as Intent.EXTRA_TEXT and the url in Intent.EXTRA_TITLE.

Anyone knows a way to get both highlight text and URLs. If this is an improvement to the carrier / manufacturer, any ideas on how widespread it is?

+4
source share
1 answer

As far as I understand, there is no reliable way to get the url from the intent of the "text / plan type" of the mime type. Browsers put the URL in EXTRA_TEXT, but other applications do not work (for example, FlipBoard).

0
source

Source: https://habr.com/ru/post/1437509/


All Articles