根據個人需求選用合適功能 //path爲本地文件絕對路徑 public void shareImage(String path) { //由文件得到uri Uri imageUri = Uri.fromFile(new File(path)); Log.d("share", "uri:" + imageUri); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri); // ArrayList<Uri> imageUris = new ArrayList<Uri>();//不需要多文件可以刪掉 // for (File f : files) { // imageUris.add(Uri.fromFile(f)); // } // shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,imageUris);//多個文件 shareIntent.setType("image/*");//選擇視頻 //shareIntent.setType(“audio/*”); //選擇音頻 //shareIntent.setType(“video/*”); //選擇視頻 //shareIntent.setType(“video/;image/”);//同時選擇音頻和視頻 startActivity(Intent.createChooser(shareIntent, "分享到")); }