Sharing content to other Apps in Android
Sharing is sending content such as text, files, or images to other apps.
Sharing Text
Intent shareIntent = ShareCompat.IntentBuilder.from(activity)
.setType("text/plain")
.setText(shareText)
.getIntent();
if (shareIntent.resolveActivity(getPackageManager()) != null) {
startActivity(shareIntent);
}
Sharing HTML Text
Intent shareIntent = ShareCompat.IntentBuilder.from(activity)
.setType("text/html")
.setHtmlText(shareHtmlText)
.setSubject("Definitely read this")
.addEmailTo(importantPersonEmailAddress)
.getIntent();
Receiving Text
``` java <activity android:name=”.ShareActivity”>
</activity>
Leave a comment