I want to develop an android application that receives documents from other apps, converts them to pdf, and sends the pdf to an online API.
My question is: How do I show my app in the list of "share to" applications that are available to most Android Apps? Is there an online tutorial somewhere?
e.g. if you click "share to" on an image, various apps show up (messages, gmail, email, etc) - how do I add my app to this list?
You can use
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "Here is the share content body";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
sharingIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{"[email protected],[email protected]"});
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,URI.parse(filePath));
startActivity(Intent.createChooser(sharingIntent, "Share via"));
I have just copied the code from Mobile TetPlus and added my few statements too. You can read the description there
Note : You have to set your mime type according to the data you want to send/share.
For example
If you want to simply send text then use plain/text mime type.
If you want to send audio files then use audio/mp3 or audio/3gp mime type.
If you want to send image files then use image/jpeg or image/png mime type.
I think you want to be able to List your application in that Dialog.
which got open when a Share Intent is called.
Then IntentFilter are your way to go.
Please consider the links here
What are Intent Filter - StackOverflow Question
Android Docs
Intent Filters
Android Manifest - Intent Filter Element
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With