摘要:Android - 使用相機拍照
if(Macro.GetSdkVersion() <= Build.VERSION_CODES.FROYO){
;
} else {
File file = new File(Environment.getExternalStorageDirectory() + FILE_PATH);
if (!file.exists()) {
file.mkdir();
}
File tmpFile = new File(
Environment.getExternalStorageDirectory() + FILE_PATH,System.currentTimeMillis() + ".jpg");
outputFileUri = Uri.fromFile(tmpFile);
takeIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
}
if(Macro.GetSdkVersion() <= Build.VERSION_CODES.FROYO){
;
} else {
File file = new File(Environment.getExternalStorageDirectory() + FILE_PATH);
if (!file.exists()) {
file.mkdir();
}
File tmpFile = new File(
Environment.getExternalStorageDirectory() + FILE_PATH,System.currentTimeMillis() + ".jpg");
outputFileUri = Uri.fromFile(tmpFile);
takeIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
}
startActivityForResult(takeIntent, ACTION_ID);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Bitmap srcBmp01 = null ;
if (resultCode == RESULT_OK) {
if (requestCode == ACTION_ID){
if(Macro.GetSdkVersion() <= Build.VERSION_CODES.FROYO){
srcBmp01 = (Bitmap) data.getExtras().get("data");
}else{
String filePath = outputFileUri.getPath();
srcBmp01=BitmapFactory.decodeFile(filePath,options);
}
}
}
}