Android Photo App 05 save image file

preview_player
Показать описание
How to build an Android app that works with the camera and image gallery. This video shows how to call the camera intent in Android. using an implicit intent. The image will be saved to a file and the file name will be passed back to the main activity using the onActivityResult method. Demonstrates permissions in the manifest, Implicit and explicit intents, startActivityForResult, requestcode, onActivityResult, Uri, the Glide custom library, saving images to files.

The statement below doesn't seem to work anymore.

// Ensure that there's a camera activity to handle the intent

}

You can either comment it out and hope the the phone has a camera or use this

// Ensure that there's a camera activity to handle the intent
if (getApplicationContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_CAMERA)) {
}

Рекомендации по теме
Комментарии
Автор

The statement "if != null) {}" doesn't seem to work anymore. You can either comment it out and hope the the phone has a camera or use this if

shadsluiter
Автор

The Android tutorial page now uses the Path for the file authority as this

<external-files-path name="my_images" path="Pictures" />

shadsluiter
Автор

Thank you Shad. Really appreciate you guiding us.

For those like me who encountered the Illegal Exception, I googled and found the solution below as it seems the issue is in the "path" not recognized implicitly.

Error Issue: IllegalArgumentException: Failed to find configured root that contains

<?xml version="1.0" encoding="utf-8"?>
<external-files-path name="my_images" />
</paths>


Cheers mate!

jaime
Автор

Good one!! Helped me with my project!

JaCkMiller
Автор

Please do a full android Studio tutorial! Their documentation is horrid! You're a life saver!

thexs
Автор

To fix the filepath error all I did was delete the and replaced it with path="Pictures" I dont understand how that solved the problem but it did. Pretty simple fix for anyone who is stuck.

warrenpeterson
Автор

if you get a "failed to find configured root" error in API 30, add <root-path name="root" path="/" /> to your file-paths xml

jtlewis
Автор

Cant continue to the rest of the Android Photo App tutorial because the pictures I take are not saved.

Manifest is all in order, path file, and package names. Get no errors when running the app and when taking the pictures.
But the pictures just arent saving for some reason.

Anyone else have a similar problem?

NetiTwine
Автор

I am unsure if anyone had this issue or not, but I was running the Pixel XL, API 30 emulator and after solving a few of my issues, I ran into another issue with everything else working. The camera was upside down, in both the main camera app and in the photo app. If anyone has a solution for this, feedback would be greatly appreciated. I cannot find much online.

nicolashagen
Автор

@7:40
If I keep the authorities address the same as copied from Google Developer both in manifest and in dispatch method, the app worked well, otherwise, following the video instruction to make customized address it always throw illegalArgumentException.

flowersunny
Автор

These videos don't work with androidx libraries / slight changes are needed

MrAizakku
Автор

Not sure why mine wasnt working since it couldnt find the file path or something. It would just stay on the main screen no matter how many times i clicked take. Had to replace the code in the XML file with this

<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path
name="external"
path="." />
<external-files-path
name="external_files"
path="." />
<cache-path
name="cache"
path="." />
<external-cache-path
name="external_cache"
path="." />
<files-path
name="files"
path="." />
</paths>


poster was Mitul Varmora

I also had to comment out the "if != null) {}" statement, again no sure why

kodyoneill