java.io.FileNotFoundException on fileInputStream

Show the value of global path

What android version and what filescope are you using?

What does taking a picture have to do with saving this image using Canvas?

grafik

To shorten it, post the aia and explain precisely what the goal is.

Which Android version and what did you set for DefaultFileScope in the Designer?

My Android is 10,
DefaultFileScope is Shared

about : What does taking a picture have to do with saving this image using Canvas ?
why not? I only want to have an image saved on the phone to test the extension then if there is a better way no problem I am here to learn.
This app is only a test for the extension that I am developing, the goal of the extension is to upload an image file on a web server

Thank You
Marco
UploadImage.aia (12.3 KB)

Testing in companion on Android 10, I get no error, but no content in the response textbox

Where is the FileStack, where does the image go ?

Hi @TIMAI2, I did not post the extension because there are some personal data and it is not yet ready (obviously) but You should have a log file called FileStackLog.txt with the exception.
Here the source
FileStack.txt (6.7 KB)

Thank You
Marco

I'll need to leave this. I do not work with file storage other than to the ASD, it seems pointless when there is a workable read/write location for files...

Ok, but as I said: The taken picture (with Camera comp.) has nothing to do with your Canvas image!

Post a link to this extension (or is it your own, not published ext?).

English is not my language so maybe I don't understand what you want to tell me.
In my app, after taken the picture, i set the canvas background image with the image taken (this is the connection between the camera and canvas) the i save the file with the name CB.jpg, tht is an image taken from the camera.

Btw, this path wont work on Android 11+ ...
There you have no access to the root dir of the external storage.

To work with ASD files what steps I have to do?
DefaultFileScope: App or Private ? or something else?

App,
but you told us you've already read my guide.

1 Like

The App just started

Take the picture

AfterPicture set as background of Canvas and the saved

After click on button Image to check if the path is correct

Last the image saved CB.jpg in the root

This is what happen in my Android 10 phone

Well I try with App
thank You for yor patience

Marco

Still not sure why you need to create/save the canvas background image if you already have the camera image?

Well this is the first time that I work with image, so i found this way to save the image using canvas with the name file that I want, if you point me to use the image created with camera well no problem, better, but I suppose that not change the main problem of FileNotFoundExecption, but why not to try
Thank You @TIMAI2
Marco

Ok sorry, I've overlooked something.
Try with ASD or this, it should work on all Android version:

If you can post necessary code from your extension then the topic can be moved to Extension Development - MIT App Inventor Community category where more people will be able to help you.

1 Like

I solved, the problem about java.ioFileNotFoundException was
the line code: File file = new File(OBJECT_LOCATION);
if OBJECT_LOCATION is file:///........ becomes file:/...... so the path is incorrect
How I solved, instead to use:
java.io.File;
I used:
java.nio.file.Path;
java.nio.file.Paths;

I changed ->
File file = new File(OBJECT_LOCATION);
with ->
Path path = Paths.get(URI.create(OBJECT_LOCATION));
and then to read the file
byte[] buffer = java.nio.file.Files.readAllBytes(path);

Easy....after You understand where the problem lies

Ciao
Marco

java.nio classes were added to android in latest version. (Don't know which one)