• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help with Camera2 ID

JamesNSco

Lurker
I'm at the very beginning of trying to develop a simple Camera app with Camera 2 app (this is more of a learning project more than anything). Anyway i'm at step one, trying to get a list of camera's that are on my device.

Trying to figure out Android documentation I came up with this (shown at the bottom of this post), but admittedly i'm a little lost at whats going on and i'm nut sure if my code actually works, although Eclipse doesn't give me errors when I run it.

My second question is, where is the camera Ids listed if i were to have coded this correctly, would my Eclipse's Console list the cameras on my phone, or the DDMS?

I am using Eclipse, although I know there is now Android Studio, but Eclipse is what the books I've been learning from use, and i'm more accustom to it.

The code I wrote thus far is as follows:



package mainCamera;
import android.R.string;
import android.app.Activity;
import android.content.Context;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraManager;
import android.os.Bundle;

public class Main extends Activity {
@override
protected void onCreate(Bundle saveInstanceState){
super.onCreate(saveInstanceState); }

public String find(){
CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
String cameraId = null;
try {
manager.getCameraCharacteristics(cameraId);
} catch (CameraAccessException e) {
e.printStackTrace(); }
return cameraId; }


}
 
Back
Top Bottom