简体   繁体   中英

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, eg to share a quote in a social networking app while automatically linking the source.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM