Call the system sharing Function and call the sharing function.

Source: Internet
Author: User

Call the system sharing Function and call the sharing function.





// Share text Intent intent = new Intent (Intent. ACTION_SEND); intent. putExtra (Intent. EXTRA_TEXT, "text to share. "); Intent. setType (" text/plain "); startActivity (Intent. createChooser (intent," share "));

// Share image Uri = uri. fromFile (new File ("/storage/emulated/0/DCIM/Camera/img.jpg"); Intent intent = new Intent (Intent. ACTION_SEND); intent. putExtra (Intent. EXTRA_STREAM, uri); intent. setType ("image/jpeg"); startActivity (Intent. createChooser (intent, "share "));

// Share a series of images in ArrayList <Uri> uris = new ArrayList <> (); uris. add (Uri. fromFile (new File ("/storage/emulated/0/DCIM/Camera/img.jpg"); uris. add (Uri. fromFile (new File ("/storage/emulated/0/DCIM/Camera/aaa.jpeg"); Intent intent = new Intent (Intent. ACTION_SEND_MULTIPLE); intent. putParcelableArrayListExtra (Intent. EXTRA_STREAM, uris); intent. setType ("image/*"); startActivity (Intent. createChooser (intent, "share "));

The principle should be as follows: for example, a registered Action is Intent. the ACTION_SEND Activity only calls this Activity during sharing and transfers data to the Activity. These activities are carried out on the mobile phone and do not need to be connected to the Internet, only Internet permissions are required.

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.