0

I have a application that has a text field, something like a sample notepad application. I want to have send option where I need to create intent to send the text to all possible applications like gmail, sms, facebook, twitter, etc... and i also want the other way also. I mean when the user clicks on send from other application they need to see my application as a option to receive text .

And In this operation if the application is a mail application for sending text to, example the gmail application, I want to have few files from my sd card attached to the mail.

Please let me how to do this in my application. Thank you for your help and time.

Vinod
  • 31,933
  • 35
  • 96
  • 119
  • 1
    Do your research using stack overflow and Google before asking a question. Answers to all your questions are available in SO. It is a long application and answering it in one go will be quite a task – Andrew Anderson Jul 17 '11 at 16:01

1 Answers1

0

For registering your app as a receiver you have to use an intent as this:

<intent-filter>
   <action android:name="android.intent.action.SEND" />
   <data android:mimeType="text/plain" />
</intent-filter>

About sharing look at the documentation:

http://developer.android.com/reference/android/content/Intent.html

You should wrap it in a chooser (createChooser(Intent, CharSequence))

example:

Intent i=new Intent(android.content.Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_SUBJECT, "hi");
i.putExtra(Intent.EXTRA_TEXT, "your data");
startActivity(Intent.createChooser(i, "example"));
matsjoe
  • 1,480
  • 12
  • 17
  • Can I include attachments to GMAIL? I have a location of file with in my app, like "file://mnt/sdcard/test.jpg". I want this to get attached as a file attachment in gmail application. Is this possible. If so how to do this. Thank you for your above answer. – Vinod Jul 18 '11 at 01:49
  • I'm not 100% sure but I believe it is i.putExtra(Intent.EXTRA_STREAM. Uri.parse(pathtofile); otherwise look at this http://stackoverflow.com/questions/2206397/android-intent-action-send-with-extra-stream-doesnt-attach-any-image-when-choos – matsjoe Jul 18 '11 at 09:33