return a mapping of all camera ids to matching camera info - Android Camera

Android examples for Camera:Camera Feature

Description

return a mapping of all camera ids to matching camera info

Demo Code


//package com.java2s;

import android.hardware.Camera;

import java.util.HashMap;

import java.util.Map;

public class Main {
    /**//from   w w w . j a va 2  s  .  c o  m
     * @return a mapping of all camera ids to matching camera info
     */
    public static Map<Integer, Camera.CameraInfo> getCameras() {
        Map<Integer, Camera.CameraInfo> cameraMap = new HashMap<Integer, Camera.CameraInfo>();

        int numberOfCameras = Camera.getNumberOfCameras();
        Camera.CameraInfo cameraInfo = null;

        for (int i = 0; i < numberOfCameras; i++) {
            cameraInfo = new Camera.CameraInfo();

            Camera.getCameraInfo(i, cameraInfo);

            cameraMap.put(i, cameraInfo);
        }

        return cameraMap;
    }
}

Related Tutorials