A. android 調用系統照相機拍照後獲得圖片路徑
{privateUrimOutPutFileUri;
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ButtontakePiCButton=(Button)this.findViewById(R.id.button1);
takePiCButton.setOnClickListener(this);
}
@Override
publicvoidonClick(Viewv){
switch(v.getId()){
caseR.id.button1:
saveFullImage();
break;
default:
break;
}
}
privatevoidsaveFullImage(){
Intentintent=newIntent(MediaStore.ACTION_IMAGE_CAPTURE);
//文件夾aaaa
Stringpath=Environment.getExternalStorageDirectory().toString()+"/aaaa";
Filepath1=newFile(path);
if(!path1.exists()){
path1.mkdirs();
}
Filefile=newFile(path1,System.currentTimeMillis()+".jpg");
mOutPutFileUri=Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT,mOutPutFileUri);
startActivityForResult(intent,1);
}
@Override
protectedvoidonActivityResult(intrequestCode,intresultCode,Intentdata){
super.onActivityResult(requestCode,resultCode,data);
if(requestCode==1){
UriimageUri=null;
if(data!=null){
if(data.hasExtra("data")){
Bitmapthunbnail=data.getParcelableExtra("data");
//處理縮略圖
}
}else{
//處理mOutPutFileUri中的完整圖像
}
}
}
}