Android调用摄像头拍照
添加权限:
<!-- 摄像头权限 --> <uses-permission android:name="android.permission.CAMERA"/> <!-- SD卡读写权限 --> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
关键代码:
/** * @ClassName: addPictureListenerImpl * @Description: 添加图片 * @author chenzheng * @date 2014-5-6 下午2:51:46 */ private class addPictureListenerImpl implements OnClickListener { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent,1); } } protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (resultCode == RESULT_OK) { Bundle bm = data.getExtras(); Bitmap bitmap = (Bitmap) bm.get("data"); pic1.setImageBitmap(bitmap); } } }
相关推荐
zhangsunyucong 2015-10-26
ChaoYoung 2014-08-28
kiduo0 2014-06-03
woolnil 2012-02-28
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