从Android 2.3 Gingerbread开始,原生支持前置摄像头。下面我们看看如何在程序里来调用前置的摄像头。

第一种方式是采用MediaStore,调用系统原生的相机。
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("camerasensortype", 2); // 调用前置摄像头
intent.putExtra("autofocus", true); // 自动对焦
intent.putExtra("fullScreen", false); // 全屏
intent.putExtra("showActionIcons", false);
startActivityForResult(intent, PICK_FROM_CAMERA);

本文介绍了在Android系统中如何调用前置摄像头。从2.3版本开始,Android原生支持前置摄像头。可以通过MediaStore调用系统相机,或者使用Camera框架,利用其丰富的API和接口实现自定义功能和图像处理效果。
最低0.47元/天 解锁文章





