Get HTML from web page shared from browser through intent

156 views Asked by At

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!

1

There are 1 answers

0
CommonsWare On

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