Make your app social

Using a neat little feature you can make your app social using 5 lines of code.

The idea is to launch an intent of type ACTION_SEND which will pop up an Android dialog box for sharing. Every activity that binds itself to this activity will be displayed. Usually activities that have sharing capabilities (like Linkedin, Twitter and Facebook) will show up in that list.

Share using SEND_TO

Use the following code:

Intent intent=new Intent(android.content.Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");

intent.putExtra(Intent.EXTRA_TEXT, "Description");
activity.startActivity(Intent.createChooser(intent, "Dialog caption"));

Ain’t that simple ?

In case you want specific activities to handle your request then make sure to change the type, usually most social apps will listen to text/plain.


Leave a comment

Filed under API

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s