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!
Use an HTTP client API (OkHttp,
HttpUrlConnection
, etc.) and make an HTTPGET
request for that URL. IOW, do what a Web browser does.