Camera object does not trigger afterpicture event at first picture taken

First to start that I believe the tool you have created is great.
Am playing around with an application and started adding pictures to a log input.
The intersting thing is on Motorloa running Android 9, the first time I take a pciture and return to the programm, the afterpicture event is not triggered. Then when I enter the camera again the second time I take a picture then it does catch the picture.

This happens every time when I open the application.

To avoid any doubt on any interaction with other objects I created a sample application, with just camera, a button to call camera and an image box to capture the picture.

Again same behaviour, first picture is not received by the app, the second one and any other pictures taken are received. As a side note, looking in my Pictures folder, the first picture is taken and stored on the phone (on both applications), as such the error is not there?

Slowly going crazy, I then installed same App on my BQ Aquarius U2, running Android 7.1.2.
With this one there was no issue, first picture is received properly by the afterpicture event?

Not sure where to look further? Any idea what culd be causing this issue?
Does anybody run into ths same isseu on Android ?

thanks all for any feedback that you could give


This works on my Samsung Galaxy S8 running Android OS v9.0:

AfterPictureTest.aia (1.8 KB)

Hi Ken
great and thanks for your quick feedback! As such it is not Android 9 and App Inventor issue, but something to do with the Motorola Camera app being used I assume?

Is there any log file that I can see what is happeing behind the scene what could be going on with this? it is very strange, as it is only at start up of the app and the first time it goes to the camera app that it doesnt come back and doesnt trigger the after picture, then at the second and any following call to camera it works fine…

After your post installed a seperate app, called Open camera. And using that one to take pictures, it worked perfectly. As such the standard camera app from Motorola seems to be the issue. So 100% it is the Motorla package

1 Like

It’s strange that it works on the second try.

Possibly the adb logs may provide some insight.

many thanks… will set it up and see if the log file triggers anything… Yes, very strange on second camera trigger it works… It started bugging me. Also on my main app am using sliders, and at the first camera trigger they reset to OFF, while there is nothing in my code to trigger this.

If I get anything in the log files, will post it

1 Like

Please explain more on this.

Hi Ken

only error message i find in the log when it fails to get the picture,

the log message I find with first picture is: 05-18 00:45:46.577 1930 2030 E InputDispatcher: channel ‘11eb541 appinventor.ai_sergenugteren.test_camera/appinventor.ai_sergenugteren.test_camera.Screen1 (server)’ ~ Channel is unrecoverably broken and will be disposed!

when running the log the second time I take a picture I get not a single error message in the log for the app inventor app


1 Like

Did you get any error message (from your device) after taking the first picture?
Post the aia and try Taifun's Camera extension: App Inventor Extensions: Camera | Pura Vida Apps
Did you get the same issue with it?

Specify the device, exact name, model number, ...

1 Like

test_camera.aia (1.6 KB)

Hello adding the simplistic application used, just to show nothing fancy and it still fails the first picture. As mentioned previous it does capture the first picture and stores it in the /Pictures folder, just dont get the AfterPicture event.

Have tried another camera (Open Camera) and that works, as well downloaded the test app from Taifun, with that app there is never an issue with the first picture.

On the log files looking at all the motorola camera log entries, seeing numerour of messages, but same log messages received when taking first and second picture.

Android version 9
Motorola Moto G7 Play


1 Like

What happens if try this aia?
test_camera2.aia (2.4 KB)

… and if you take Ken’s aia, did you get this on the first run (picture):


If not, you are correct, that the .AfterPicture event is not driggered (for the first time).
(That would be really strange, since this error would have to occur often and have been discussed in the relevant forums a long time ago.)

But if true, try this:

PS: Without this being clarified so far, however, I assume that the tests were carried out with the compiled app (APK). Or? If not, do it!

Hi Anke
exactly, I do not get the label with the JPG created.
I build the app in apk package

Have installed your updated app with the permissions, at first run it sets the label to the permission, then press button to go to Motorola camera app to take picture, and when returns after picture. Picture is not loaded. Interestingly the label for permission is reset as well

Then retrying running the app, but now using the Open Camera application as the camera, again no problem and it loads the picture at first try.


This normal as this is only triggered once in the PermissionGranted event.

Does this mean that you closed the app (removed from Task Manager?) and opened the app again and then the first picture works?

… and did you get any response from the .AfterPicture event?
Try this:

And what happens, if you try this (to reload the screen after permissions granted):

no sorry am not explaining myself properly. I mean when I run the app with the other camera package, which is not the motorola camera app, but an app called: Open Camera then there is no issue

Further added the label to capture the get picture name/location but no response from first image, only at second picture. Also tried the same with reopening the screen and closing, as per your suggestion. Again same result, first picture does not get the trigger event.


We don't want to give up yet: test_camera2a.aia (36.1 KB)

This approach doesn't use the .AfterPicture event.

I made a few minor changes (in the aia)
It should work now.

or more compact:

Does it work that way?

I think so, it should also work on your special Motorola device,
provided that the first picture is actually created.