2

I'm looking to get the HTML from a web page shared by the user with my app.

So I have this intent filter:

<intent-filter>
    <action android:name="android.intent.action.SEND"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="text/plain"/>
</intent-filter>

And the code in my activity:

String action = intent.getAction(); 
if (action.equalsIgnoreCase(Intent.ACTION_SEND) && 
intent.hasExtra(Intent.EXTRA_TEXT)) { 
    String s = intent.getStringExtra(Intent.EXTRA_TEXT); 
    output.setText(s); //output: a TextView that holds the URL 
} 

This outputs the link.. but I need the HTML. Any thoughts? thanks!

Alejandro
  • 1,159
  • 3
  • 16
  • 30

1 Answers1

0

Use an HTTP client API (OkHttp, HttpUrlConnection, etc.) and make an HTTP GET request for that URL. IOW, do what a Web browser does.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491