Question

I have a flashlight app, and if the app is paused, the camera is released. Be it the home button or power button. I want the camera to stay alive when either of these are pressed and released when I close the app completely. How do I go about doing this?

Was it helpful?

Solution

This is intended functionality to ensure you do not consume more power than necessary, and that other software on the device can obtain access to the camera on demand. Some useful information on the Activity lifecycle can be found here.

Generally, an Android developer's options are:

  1. Build a custom Android firmware that gives your app privileged access to the camera. This option is usually only really feasible if you are providing dedicated hardware, with this firmware and your app pre-installed.

  2. Approach your app design in a different way, that does not require the use of the camera when it is not in the foreground.

  3. Stick with the existing behaviour, and detail the caveats to the user on the market (and possibly as a first-time pop-up dialog to grab their attention) to reduce the number of complaints.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top