'Android - where are videos taken from intent stored?
Let's say I have a method inside my activity that looks like this:
private void dispatchTakeVideoIntent() {
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (takeVideoIntent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
}
}
Then if everything works out fine, I access the taken video by its URI:
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent intent) {
if (requestCode == REQUEST_VIDEO_CAPTURE && resultCode == Activity.RESULT_OK) {
Uri videoUri = intent.getData();
// process video
}
}
Where does the video actually reside at this point? Is it temporarily stored in memory or does it get saved to permanent storage?
If I want my app to reliably access that video at some later point, what's the best way to go about this? Do I have to copy the video to my app's storage folder(s)?
Solution 1:[1]
Where does the video actually reside at this point?
It will reside wherever the user's camera app elects to put it. There are hundreds of different camera apps, both pre-installed by manufacturers and user-installed from the Play Store or elsewhere.
Is it temporarily stored in memory or does it get saved to permanent storage?
That is up to the camera app.
If I want my app to reliably access that video at some later point, what's the best way to go about this?
You can try passing a content Uri value via EXTRA_OUTPUT as an extra on your Intent. You can use FileProvider to get that Uri, pointing to some file in a location that you control (e.g., getFilesDir() on Context). Most camera apps should honor this extra, but not all will.
Or, you could copy the video, as you suggest.
Or, you could use a camera library (e.g., FotoApparat, CameraKit-Android) and record the video within your own app.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | CommonsWare |
