Alexander Caravitis
Alexander Caravitis

Reputation: 51

Develop android application with "share-to" functionality

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?

Upvotes: 3

Views: 2813

Answers (2)

Adil Soomro
Adil Soomro

Reputation: 37729

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

Upvotes: 2

Kartik Domadiya
Kartik Domadiya

Reputation: 29968

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.

Upvotes: 4

Related Questions