Camera plugin for android devices?

When using the camera on android my cordova app is killed and restarted after the camera is closed. This happens because of the android lifecycle described here:

I don’t like the solution described in the document because I think using the camera should be an inapp action and not close and restart the app.
I also tried the following plugin: but it doesn’t work for me at all.

Does someone knows a working solution for the problem?

BTW.: If you use the camera plugin in your app you should activate Don't keep activities in the Developer options -> Advanced and try the camera. If it doesn’t work your app may won’t work on some android devices. We saw it on hawei devices most of the time.

Have you tried the MediaCapture plugin? I’ve had pretty good luck with it.

1 Like

Hi, did you try to build and run with --prod mode enabled? I strongly recommend you try.
I experienced issues with my phone and Camera plugin (a fast Android, Xiaomi Redmi Note 4), for 2 reasons:

  1. in dev mode, your app is considerably slower, hence you get a console message for native plugins like "you exceeded the 5 seconds no response… and Camera plugin crash and make your app restart
  2. my phone use “HDR” mode by default, when I switched back to “standard quality mode” for photos, and back in dev mode, I suddenly did not have any crash any more, even in android build/run --dev mode. So this might be a bug of Camera plugin itself too, that don’t get HDR mode.

Hope it helps :slight_smile:

1 Like

Thank you for your reply.

The issue doesn’t occur on my development phone but with the production version on particluar phones. The app doesn’t crash but the main cordova activity gets closed and restarted after closing the camera.
This is done by android os to avoid memroy problems or save cpu time I guess.

If this will happen or not depends on the phone and the android derivate. It seems that the huawei version of android is very restrictive so the issue was mainly reported to us by huawei users.