Activity Starter Camera

You may want to have access to the full native camera app when you take a photo from within your app, this is how you do it. This is tested and demonstrated using the companion app on an Android 13 device.

Why do this:

  • Images taken when the phone is held in portrait position are returned in the correct orientation (unlike with the camera component)
  • you may want the full features of your native camera app, which may not be available when using the camera component
  • this works, whilst using the intent:, as shown in the documentation does not actually take/store an image file (more work is required with EXTRAS and possibly java code needed for this)

ActivityStarterStillCamera.aia (3.5 KB)

  1. we start off by getting the length of the number of items in the /DCIM/Camera folder
  2. We then call the camera with the activity starter, and start the clock timer
  3. We are taken out of the app to the full native camera app, to take a photo
  4. Use the Back button to return to the app
  5. As the clock timer fires, it check if the length of items in the /DCIM/Camera has increased, and if so
    a. stops the clock
    b. gets the file name and path of the newest image
    c. shows the file path in a label and the actual photo in an image component

My thanks to @Anke for her work on helping and ideas to return the image to the app.

Things this demo does not do:

  • setup the environment to work on any android version
  • provide for copying or moving the latest photo to other locations
  • handle permissions for file access and camera when compiled
  • error check if a photo is not taken (the clock will then just keep running)
  • provide options if a device does not save photos by default to /DCIM/Camera
  • cope with the possibility that some other app, running in the background, adds a file to /DCIM/Camera at the same time a photo is taken!

The demo is created without extensions.

Have fun :slight_smile: