Android: Call the system sharing function. android calls
Sample Code:
/*** Call the system sharing Function * Created by admin on 15-4-13. */public class extends Activity {@ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. pai_layout);} // share the text public void shareText (View view) {Intent = new Intent (); Intent. setAction (Intent. ACTION_SEND); Specify intent. putExtra (Intent. EXTRA_TEXT, "This is my Share text. "); specifies intent. setType ("text/plain"); // set the title of the share list, and the share list startActivity (Intent. createChooser (shareIntent, "share to");} // share a single image public void shareSingleImage (View view) {String imagePath = Environment. getExternalStorageDirectory () + File. separator + "test.jpg"; // uri Uri imageUri = Uri from the file. fromFile (new File (imagePath); Log. d ("share", "uri:" + imageUri); // output: file: // storage/emulated/0/test.jpg Intent specify Intent = new Intent (); Specify Intent. setAction (Intent. ACTION_SEND); Specify intent. putExtra (Intent. EXTRA_STREAM, imageUri); Specify intent. setType ("image/*"); startActivity (Intent. createChooser (shareIntent, "share to");} // share multiple images public void shareMultipleImage (View view) {ArrayList <Uri> 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 specify Intent = new Intent (); Specify Intent. setAction (Intent. ACTION_SEND_MULTIPLE); specifies intent. putParcelableArrayListExtra (Intent. EXTRA_STREAM, uriList); Specify intent. setType ("image/*"); startActivity (Intent. createChooser (shareIntent, "share "));}}
Page effect: