简体   繁体   中英

How to take picture from front camera in android2.2

can anybody tell How to take picture from front camera in android2.2 can anybody provide sample code

Thanks

You should use the Camera API with the right camera index:

Camera camera = Camera.open();
Camera.Parameters parameters = camera .getParameters();
parameters.set("camera-id", 2);
camera .setParameters(parameters);

Don't forget to set the permissions correctly:

<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.CAMERA" />

Please note that in most cases it will be camera #2, maybe there is another automatic way to find out. You try this one for now. If I'll find something automatic I'll update the post.

And you can take the complete code from here (just replace the Camera.open): Camera Tutorial

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM