龍巖易富通網(wǎng)絡(luò)科技有限公司

龍巖小程序開發(fā),龍巖分銷系統(tǒng)

android調(diào)用系統(tǒng)攝像頭拍照圖片和視頻及回調(diào)

2015.09.10 | 746閱讀 | 0條評論 | 未命名

[php] public?void?onClick(View?v)?{???//啟動系統(tǒng)相機 Intent?intent?=?new?Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent,?CASE_CAMERA); } [/php]   [php] public void onClick(View v) { //啟動系統(tǒng)視頻攝像頭 Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); startActivityForResult(intent, CASE_VIDEO); } [/php] 回調(diào): [php] @Override ????protected?void?onActivityResult(int?requestCode,?int?resultCode,?Intent?data)?{ ????????try{ ????????????if(resultCode==Activity.RESULT_OK){ ????????????????if(requestCode==CASE_CAMERA){ ????????????????????typeMulti?=?0; ????????????????????Bundle?extras?=?data.getExtras(); ????????????????????Bitmap?bitmap=?(Bitmap)?extras.get("data"); ????????????????????path?=?IOUtils.saveImg(bitmap);????//返回圖片保存在本機中的目錄 ????????????????????/*Toast?toast=Toast.makeText(this,?"相片已保存在:SDcard/DCIM/Camera目錄中",?Toast.LENGTH_LONG); ????????????????????toast.setGravity(Gravity.BOTTOM,?0,?0); ????????????????????toast.show();*/ ????????????????????isUploadPhoto(bitmap); ????????????????} ????????????????if(requestCode==CASE_VIDEO){ ????????????????????typeMulti?=?1; ????????????????????path?=?data.getData().toString(); ????????????????????/*Toast?toast=Toast.makeText(this,?"視頻已保存在:"+path,?Toast.LENGTH_LONG); ????????????????????toast.setGravity(Gravity.BOTTOM,?0,?0); ????????????????????toast.show();*/ ????????????????????uploadVideoDialog(); ????????????????} ????????????} ????????}catch(Exception?e){ ????????????e.printStackTrace(); ????????} ????} [/php]

贊 (

發(fā)表評論