public void startSendToIntent(String packageName, String className, String mimetype, String urls) { // urls: "/storage/sdcard0/file1.mp4;/storage/sdcard0/file2.mp4;" // mimetype: "video/mp4" /* All url using ";" as the divider */ String[] urlArray = urls.split(";"); ArrayListuris = new ArrayList (urlArray.length); for (int i = 0; i < urlArray.length; i++) { uris.add(Uri.fromFile(new File(urlArray[i]))); } Intent intent = new Intent(); intent.setClassName(packageName, className); intent.setType(mimetype); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); if (uris.size() > 1) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); intent.putExtra(Intent.EXTRA_STREAM, uris); } else { intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, uris.get(0)); } Log.i(TAG, "startSendToIntent: packageName:"+packageName+" className:"+className+" mimetype:"+mimetype+" urls:"+urls+" uris:"+uris); mActivity.startActivity(intent); }
Thursday, December 5, 2013
Share file(s) using Intent
Subscribe to:
Posts (Atom)
[ROM] Samsung S7 Stock Firmware BRI (Taiwan台灣)
Latest ROM: G930FXXU1DQEU Download: https://kfhost.net/tpl/firmwares.php?record=B7E6DE774E3811E7963AFA163EE8F90B Reference: http://...
-
In Android 4.1 (API 16) and above, MediaCodec is introduced by Android. By using MediaCodec, we can easily decode video without using Androi...
-
#include <sstream> #include <assert.h> // include in android platform-9 or newer #include <android/asset_manager.h> #inclu...
-
Latest ROM: G930FXXU1DQEU Download: https://kfhost.net/tpl/firmwares.php?record=B7E6DE774E3811E7963AFA163EE8F90B Reference: http://...