Camera doesn't return image

A bug was fixed for the nb181 release (Dec 19th 2019)

“[Bug] Fixed issue where Camera would not require WRITE_EXTERNAL_STORAGE permission in compiled apps though it was needed to save pictures”

Have you updated your app since then ?

If still not saving an image, have you tried adding a request for “WRITE_EXTERNAL_STORAGE” permission in your app and re-compiling ?

Thank you for your answer Tim.

Indeed, I saw this release but it doesn’t work for me. I made my app few days ago, so I did it with the last release.

How can I add a request for “WRITE_EXTERNAL_STORAGE” permission ?

Thank you :slight_smile:

Something like this: (oops I spelt EXTERNAL wrong in the blocks :raising_hand_man: - slaps head)

It will only ask the user the first time.

(Note: the companion app already has this permission set, so you have to test in a compiled app)

Please let us know if this changes things…

Thank you for you time.

Unfortunately, it doesn’t work. When screen is initialized, nothing happens. I tried also to ask permission by clicking on an button but nothing happened. (I have installed the app on my phone)

Here are the blocks I used according to your advise:

I just think about it. I don’t have external storage on my phone. It is probably why it did not ask me anything.

I would like to be able to store data on my phone like before Android 10.

Thanks for trying…

thumbsup2

Just to make things confusing, EXTERNAL storage refers to your virtual sdcard on your device (internal storage > /mnt/sdcard/…

All worth a try, let us elevate to MIT see if they can replicate

in Android 10 an app can't store files in any directory anymore...
see also Android 10의 개인정보 보호 변경사항  |  Android 개발자  |  Android Developers

External storage access scoped to app files and media

By default, apps targeting Android 10 and higher are given scoped access into external storage, or scoped storage . Such apps can see the following types of files within an external storage device without needing to request any storage-related user permissions:

To learn more about scoped storage, as well as how to share, access, and modify files that are saved on external storage devices, see the guides on how to manage files in external storage and access and modify media files.

you could try the Small Camera Extension by Juan Antonio to save the taken picture in a directory of your choice and set the directory to the application specific directory...

you can find out the application specific directory by using the file extension and its ApplicationSpecificDirectory method here App Inventor Extensions: File | Pura Vida Apps

asd

Returns the application specific directory /storage/emulated/0/Android/data/<packageName>/files
you can use to read or write files without READ_ or WRITE_EXTERNAL_STORAGE permission.

@Wayne let us know if you get it running by using this workaround...

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

So with Android 10, App Inventor and similar applications are loosing their accessibility unfortunately… I can try to run something like that, I will let you know.

Thank you very much for your time :slight_smile: I really appreciate.

I used the following components:

Unfortunately I got a “Runtime Error: writing to internal storage is not supported

Each device has an external storage (/storage/emulated/0/). So uninstall the app, reinstall and you should be be ask for WRITE permission.

The problem here is that the camera issue (Fix camera failure on Android 10 by ewpatton · Pull Request #1957 · mit-cml/appinventor-sources · GitHub) has not yet been resolved in the current version of AI2. However, it has already been fixed on a test server (from @ewpatton), I checked it. Test this app that was created with this server:

https://drive.google.com/file/d/1fhG3KUcbUal54xrJSo-eOwjokN2N5hZG/view?usp=sharing

No need to ask for WRITE permission because the camera component does it automatically.
So you can only wait for the next update ...

Note:
To give users more control over their files and to limit file clutter, apps that target Android 10 (API level 29) and higher are given scoped access into external storage, or scoped storage, by default. Such apps have access only to the app-specific directory on external storage, as well as specific types of media that the app has created.

App Inventor does not yet target Android 10. It targets Android 9, so the Android 9 semantics ought to apply. There is a bug at the moment with the App Inventor Camera component affecting Android 10, and what you’re seeing is likely a symptom of that. There is a fix that has been merged that will go out in the next companion release:

I'm not quite sure if I understood that correctly.

There is no issue on Android 9, but only with Android 10 devices.
Of course the current compileSdkVersion & targetSdkVersion = 28.

You’re right. The previous issue I was thinking of was for Android 10, not Android 9. Yes everything should be working correctly on Android 9. I’ll amend my post.

1 Like

I already tested to uninstall / reinstall but it doesn’t work. I guess it’s a deeper issue linked to Android 10 that needs a significant update of App Inventor.

Thank you all. So I will just wait for the next update :slight_smile:

Did you check my test app Camera_test.apk? Does it work on your Android 10 device?

Oh sorry, I just did and yes it works!

So since this is working, I need to wait the next update, right ?

Yes, should come soon ... hopefully :wink:

1 Like

4 posts were split to a new topic: Error 908: The permission Write_External_Storage has been denied while using web component to download a file

I don't have "when screen 1 permissionGranted do" block how can I get that block can you tell me please?

In the blocks palette under Screen1:

image

image