[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ā)表評論