Can I take a picture using the front camera on Sam

2019-07-25 11:14发布

问题:

Can I take a picture from the front camera?

My application has an input form for inventory. If an user sends a data,
the user's face pic is also sent to the server for authorization / validation.

I will put the app on Samsung Galaxy Tab (Android 2.2).

Is there any way to take a picture from the front camera?

回答1:

For 2.2

    Camera cam = Camera.open();
    cam.setDisplayOrientation(90);
    cam.setPreviewDisplay(holder);

    Camera.Parameters para = cam.getParameters();
    para.set("camera-id", 2);
    cam.setParameters(p);


回答2:

To solve the error:

"The method open() is undefined for the type Camera"

import android.hardware.Camera 

This is instead of

import android.graphics.Camera

Both are given as options from eclipse only hardware one has open.