Very often, you might want to enable the ability for users to share some content (either text, link or an image) from your Android app. Users can share the content using email, twitter, Facebook, sms or through numerous other ways.
The users might already have installed some custom apps for each one of the above service. So instead of coding all these again, it would be really nice (for both your users as well as for you as a developer) if you can invoke any one of these apps, where users want to share content from your app.
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.
In my phone, it invokes the following dialog box listing the apps that have registered to get notification for this intent.
Sharing binary objects (Images, videos etc.)
In addition to supporting text, this intent also supports sharing images or any binary content. All you have to do is to set the appropriate mime type and then pass the binary data by calling the putExtra method.
Registering for the Intent
If you want your app to be listed when this Intent is called, then you have to add an intent filter in your manifest.xml file
android:mimeType specifies the mime type which you are interested in listening.
Happy sharing 😉
- Recovering Android KeyStore password
- Using WebSockets with Android to control Arduino robots
- 10 more open source Android apps which every developer must look into
- Building Robots using Android and Arduino in Google Devfestx
- Transferring data from Android using Audio
- Building Robots using Arduino and Android at DroidCon