Sharing Data to Other Apps via Share Intent in Android

34 sec read

Dear Developers

So why this is important. Because we want to develop app that is useful for user, moreover user can share the app generated content to social media (Like facebook , whatsapp, google plus, linked in etc) via other apps.

This is actually very simple

you just create a sharing intent and put some information in it before sharing . So android system will show you next screen where all available sharing providers in user devices will be present.

Next user will choose anyone of sharing provider then app generated content can be shared with other apps.

 

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.putExtra(Intent.EXTRA_STREAM,selectedBitmapUri);
sharingIntent.putExtra(Intent.EXTRA_TEXT,"Color Code "+textView.getText()+"\n"+textViewRGB.getText()+"\nShared Via "+"https://play.google.com/store/apps/details?id=in.relsellglobal.colorpickerdemo");
sharingIntent.setType("image/*");
startActivity(Intent.createChooser(sharingIntent,"Sharing"));

 

 

We have one such app Link where we have used sharing intent.

 

 

 

 

Happy coding.