Android SDK支持Android设备内置的照相机。从Android2.3开始支持多个摄像头(主要指前置摄像头和后置摄像头)。通过照片相可以拍照和录像。
“android.permission.CAMERA”
“android.permission.WRITE_EXTERNAL_STORAGE”
“android.permission.RECORD.AUDIO”
uses-feature:”android.hardware.camera”
public class MainActivity extends Activity {
private ImageView image;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
image = (ImageView) findViewById(R.id.image);
findViewById(R.id.capture).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent,1);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
if (resultCode == Activity.RESULT_OK) {
Bitmap cameraBitmap = (Bitmap) data.getExtras().get("data");
image.setImageBitmap(cameraBitmap);
}
}
}
}
Android摄像头照相机技术-android学习之旅(八)
原文地址:http://blog.csdn.net/lpjishu/article/details/45747647