I found another Android 10 device with a different manufacturer, and on that device, the above code works correctly. The fundamental difference appears to be that the first device (Motorola) never keeps the activity when it switches to the camera. The second device (Samsung) does keep the activity.
I went back to my Android 7 device, and to the Samsung Android 10 device. On both, I updated the developer settings so that activities are never kept. Now all three fail.
The problem seems to be in the flow from the Camera activity back to my activity. In capacitor-android/BridgeActivity.java
, in the onActivityResult
method, data
is always null and resultCode
is always -1
.
This leads me to suspect that there is something in the way that CameraPlugin is launching the Camera Activity that only works when the parent Activity remains alive.
The LogCat isn’t especially helpful here, but one thing I noted is that just prior to the call to processCameraImage
, I see this message:
D/Capacitor: Unable to find a Capacitor plugin to handle requestCode, trying Cordova plugins 1401879998
Where 1401879998
is the requestCode
(and -1
is the resultCode
).