Many times android app user want to share information across several social networking sites as well as other media such as sms or text etc
User might have already installed various custom apps say FB G+ Gmail etc
Android made it easy to share the content to various apps with few lines of code
Android provides a built-in Intent called ACTION_SEND for this purpose. Using it in your app is very easy. All you have to do is to use the following couple of lines.
Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/html"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<p>This is the text that will be shared.</p>")); startActivity(Intent.createChooser(sharingIntent,"Share using"));
To share binary information say images video etc you need to add some additional settings say mime type etc to achieve the same
Intent sharingIntent = new Intent(Intent.ACTION_SEND); Uri screenshotUri = Uri.parse(path); sharingIntent.setType("image/png"); sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri); startActivity(Intent.createChooser(sharingIntent, "Share image using"));
Isnt it simple