Share function of calling system

Source: Internet
Author: User

/** * Call system sharing function * Created by admin on 15-4-13.        */public class Shareactivity extends Activity {@Override protected void onCreate (Bundle savedinstancestate) {        Super.oncreate (savedinstancestate);    Setcontentview (r.layout.share_layout);        }//share text public void Sharetext (view view) {Intent shareintent = new Intent ();        Shareintent.setaction (Intent.action_send);        Shareintent.putextra (Intent.extra_text, "This is my Share TEXT.");        Shareintent.settype ("Text/plain");    Set the title of the share list and show the Share list startactivity (Intent.createchooser (Shareintent, "share to") each time; }//share a single picture public void Sharesingleimage (view view) {String ImagePath = Environment.getexternalstoragedirecto        Ry () + file.separator + "test.jpg";        The URI uri Imageuri = uri.fromfile (new file) is obtained by the file (ImagePath);  LOG.D ("Share", "uri:" + Imageuri);        Output: file:///storage/emulated/0/test.jpg Intent shareintent = new Intent (); Shareintent.setaction (Intent.action_send);        Shareintent.putextra (Intent.extra_stream, Imageuri);        Shareintent.settype ("image/*");    StartActivity (Intent.createchooser (Shareintent, "share to"));        }//share multiple pictures public void sharemultipleimage (view view) {ArrayList urilist = new arraylist<> ();        String path = environment.getexternalstoragedirectory () + file.separator;        Urilist.add (Uri.fromfile (New File (path+ "australia_1.jpg"));        Urilist.add (Uri.fromfile (New File (path+ "australia_2.jpg"));        Urilist.add (Uri.fromfile (New File (path+ "australia_3.jpg"));        Intent shareintent = new Intent ();        Shareintent.setaction (intent.action_send_multiple);        Shareintent.putparcelablearraylistextra (Intent.extra_stream, urilist);        Shareintent.settype ("image/*");    StartActivity (Intent.createchooser (Shareintent, "share to")); }}

To invoke the sharing function of the system

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.