How to implement share via option in android?

Chrishan picture Chrishan · Dec 29, 2011 · Viewed 22.1k times · Source

I want to implement something like this. share via

It should not be hard coded. If user haven't installed Dropbox there should not be a option to share via Dropbox.

Thanks in advance !

Answer

Paresh Mayani picture Paresh Mayani · Dec 29, 2011

You can do the same by using:

Intent i=new Intent(android.content.Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(android.content.Intent.EXTRA_SUBJECT,"Subject test");
i.putExtra(android.content.Intent.EXTRA_TEXT, "extra text that you want to put");
startActivity(Intent.createChooser(i,"Share via"));

Detailed example is here for your reference: http://mobile.tutsplus.com/tutorials/android/android-sdk-implement-a-share-intent/