get Camera By Direction - Android Camera

Android examples for Camera:Camera Attribute

Description

get Camera By Direction

Demo Code


//package com.java2s;

import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;

public class Main {
    public static int getCameraByDirection(int direction) {
        int numCameras = Camera.getNumberOfCameras();
        CameraInfo info = new CameraInfo();
        for (int camid = 0; camid < numCameras; camid++) {
            Camera.getCameraInfo(camid, info);
            if (info.facing == direction) {
                return camid;
            }// w w w  .  ja  v  a2s  .c o  m
        }
        return -1;
    }
}

Related Tutorials