文档及官方参考实例代码
Camera
file:///E:/baiduyunpan/android_doc_v1.0/android_doc/guide/topics/media/camera.html#considerations
调用真机中的摄像机或照相机: 1、在 清单文件中增加权限:
<uses-permission android:name="android.permission.CAMERA" />
2、使用实例:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/**
* 拍照
* @param v
*/
public void takephoto(View v){
Intent intent = new Intent();
//拍照
intent.setAction(MediaStore.ACTION_VIDEO_CAPTURE );
File file = new File(Environment.getExternalStorageDirectory().getPath(),"paizhao.3gp");
//使用到了sd卡所以还需要在清单文件中增加sd卡读写权限
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
// 开启意图
startActivityForResult(intent, 1);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Toast.makeText(getApplicationContext(), "保存成功", 1).show();
super.onActivityResult(requestCode, resultCode, data);
}
}