saschoar
saschoar

Reputation: 8230

Access selected text and URL from browser's share intent

In the Android stock browser, Chrome and most other browser apps, selecting text on a page displays a contextual ActionBar. Besides text tools, it contains a share functionality which sends the text selection to other apps, probably using sendIntent.putExtra(Intent.EXTRA_TEXT, "Selected text").

My question: can apps that have registered for that send intent (using an <intent-filter/>) access the URL of the website that the text was extracted from? In other words, is the URL passed as an EXTRA_... in the intent?

Of course one could write a test app and check for all passed extras listed here. But I was hoping for some insights or an alternative approach to send selected text and the URL from the browser (at least from the stock browser) to another app.
This would be a very useful feature, e.g. to share a quote in a social networking app while automatically linking the source.

Upvotes: 1

Views: 886

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007349

My question: can apps that have registered for that send intent (using an ) access the URL of the website that the text was extracted from? In other words, is the URL passed as an EXTRA_... in the intent?

  • I am aware of no documented and supported extras beyond EXTRA_TEXT for any browser

  • The source code of the AOSP Browser app does not show anything being added to the Intent beyond EXTRA_TEXT

  • You are welcome to dump the Intent extras Bundle and examine them for any given browser you want, to see what is included, though whether undocumented extras will be available in the future is not guaranteed

Upvotes: 1

Related Questions