Android information sharing implementation

Source: Internet
Author: User

I. Text message sharing

01
Intent intent = new Intent (Intent. ACTION_SEND );
02
// Intent. setType ("text/plain"); // plain text
03
// Share images
04
Intent. setType ("image/png ");
05
// Add an image
06
File f = new File ("/sdcard/sd.png ");
07
Uri u = Uri. fromFile (f );
08
Intent. putExtra (Intent. EXTRA_STREAM, u); // Add an image
09
Intent. putExtra (Intent. EXTRA_SUBJECT, "share ");
10
Intent. putExtra (Intent. EXTRA_TEXT, "I wowould like to share this with you ...");
11
StartActivity (Intent. createChooser (intent, getTitle ()));
Ii. Email sharing
 
01
Intent log = new Intent ("android. intent. action. SEND ");
02
Object [] arrayOfObject2 = new Object [3];
03
ArrayOfObject2 [0] = "nick ";
04
ArrayOfObject2 [1] = ":";
05
ArrayOfObject2 [2] = "content ";
06
String str1 = String. format ("@ % s", arrayOfObject2 );
07
String str2 = str1 + "what ";
08
Object [] arrayOfObject1 = new Object [1];
09
ArrayOfObject1 [0] = str2;
10
Log. putExtra ("android. intent. extra. TEXT", getString (R. string. mail_body_text, arrayOfObject1 ));
11
Log. putExtra ("android. intent. extra. SUBJECT", "email ");
12
Log. setType ("application/octet-stream ");
13
StartActivity (log );


Author: android. google

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.