I have implemented a version of the intent-based camera example in a larger cross-platform B4XPages app. It works beautifully, except on some Android phones it crashes. Only some. I've also encountered one device (Samsung Galaxy S23) that exhibited the problem but then - for no known reason - was alright. The symptom is that the camera is activated, the photo taken, but when "OK" is tapped, some minority of Android devices restart the app. iOS is solid, though my uploaded example is Android-only.
I've reworked Erel's originally-posted code to exist in a class (CameraClass) because it is called from several locations in the app.
I'm uploading an example here of several pages that duplicate the navigation model of my app. It is android only, and crashes on the same devices. I can't figure out if it's environmental or what is causing the problem. If you look at the logs, when it fails the app is simply restarted instead of returning from the camera with the image.
Remember, it usually works just fine. Just some devices...
Could someone have a look and see what you think?
Many Thanks!
I've reworked Erel's originally-posted code to exist in a class (CameraClass) because it is called from several locations in the app.
I'm uploading an example here of several pages that duplicate the navigation model of my app. It is android only, and crashes on the same devices. I can't figure out if it's environmental or what is causing the problem. If you look at the logs, when it fails the app is simply restarted instead of returning from the camera with the image.
Remember, it usually works just fine. Just some devices...
Could someone have a look and see what you think?
Many Thanks!
Log of successful camera use:
*** Service (starter) Create ***
Using FileProvider? true
** Service (starter) Start **
** Activity (main) Create (first time) **
*** mainpage: B4XPage_Created
*** start: B4XPage_Created
*** addphoto: B4XPage_Created
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
*** mainpage: B4XPage_Disappear [mainpage]
*** start: B4XPage_Appear [mainpage]
*** start: B4XPage_Disappear [mainpage, start]
*** addphoto: B4XPage_Appear [mainpage, start]
Using FileProvider? true
entering TakePicture
Calling StartActivityForResult
Completed StartActivityForResult
** Activity (main) Pause event (activity is not paused). **
*** addphoto: B4XPage_Disappear [mainpage, start, addphoto]
AddPhoto Page Disappearing
sending message to waiting queue (OnActivityResult) <--- Ahh. This is what is supposed to happen
running waiting messages (1)
Waited for ion_Event
Orientation: 6
about to call image_available
** Activity (main) Resume **
*** addphoto: B4XPage_Appear [mainpage, start, addphoto]
Log of FAILED camera use:
*** Service (starter) Create ***
Using FileProvider? true
** Service (starter) Start **
** Activity (main) Create (first time) **
*** mainpage: B4XPage_Created
*** start: B4XPage_Created
*** addphoto: B4XPage_Created
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
*** mainpage: B4XPage_Disappear [mainpage]
*** start: B4XPage_Appear [mainpage]
*** start: B4XPage_Disappear [mainpage, start]
*** addphoto: B4XPage_Appear [mainpage, start]
Using FileProvider? true
entering TakePicture
Calling StartActivityForResult
Completed StartActivityForResult
** Activity (main) Pause event (activity is not paused). **
*** addphoto: B4XPage_Disappear [mainpage, start, addphoto]
AddPhoto Page Disappearing
*** Service (starter) Create *** <---- WHOA! The app just restarted!
Using FileProvider? true
** Service (starter) Start **
** Activity (main) Create (first time) **
*** mainpage: B4XPage_Created
*** start: B4XPage_Created
*** addphoto: B4XPage_Created
*** mainpage: B4XPage_Appear
** Activity (main) Resume **