android调用系统摄像头拍照图片和视频
public void onClick(View v) { //启动系统相机 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, CASE_CAMERA); }
拍摄完成后的回调函数(在同一个activity中):
protected void onActivityResult(int requestCode, int resultCode, Intent data)方法即可 如: final int TAKE_PICTURE = 1; protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CASE_CAMERA) { if (resultCode == RESULT_OK) { Bitmap bm = (Bitmap) data.getExtras().get("data"); imgPhoto.setImageBitmap(bm); } } }
相关推荐
zhangsunyucong 2015-10-26
ChaoYoung 2014-08-28
kiduo0 2014-06-03
yinbaoshiguang 2011-10-31
rookieding 2011-10-21
冰川孤辰 2011-10-09
yeaperyeo 2011-07-15
csdnuuu 2019-12-27
GoAheadY 2010-10-13
满城风絮 2011-06-19
guizhongyun 2014-12-27
cf 2012-12-05
Ifree团队 2011-10-30
思捻如枫 2011-08-19
ALDRIDGE 2011-02-23