/**
* 启动系统相机
*
* @param view
*/
public void takePhoto(View view) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CASE_CAMERA);
}
拍完成照后的回调函数如下:
/**
* 拍照后的回调函数
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
try {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == CASE_CAMERA) {
Bundle extras = data.getExtras();
//获取图片信息
Bitmap bitmap = (Bitmap) extras.get("data");
//保存图片
String path = Environment.getExternalStorageDirectory().getAbsolutePath()+ "/tmp";
saveImage(bitmap,path);
}
}
} catch (Exception e) {
如果觉得《android调用摄像头自动拍照 Android应用中调用手机摄像头拍照并保存详解》对你有帮助,请点赞、收藏,并留下你的观点哦!