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.