Returns the number of cameras accessible to the Android API. - Android Camera

Android examples for Camera:Camera Feature

Description

Returns the number of cameras accessible to the Android API.

Demo Code


//package com.java2s;
import java.lang.reflect.Method;

import android.hardware.Camera;
import android.util.Log;

public class Main {

    public static int numberOfCameras() {
        try {//  w ww.jav  a2  s .co m
            Method m = Camera.class.getMethod("getNumberOfCameras");
            return ((Number) m.invoke(null)).intValue();
        } catch (Exception ex) {
            Log.d("number of cameras", "((())) " + ex);
            ex.printStackTrace();
            return 1;
        }

    }
}

Related Tutorials