@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_CAMERA) {
String tempPhotoPath = getTempPhotoPath(register.getInsid());
//这是获取生成文件的大小,奇怪的是这里获取的是0,其他手机都不会我估计是6.0 调用系统相机有改变???
long size = FileUtil.getFileSize(tempPhotoPath);
Log.i("TAG2", "-------1--------初始大小size:" + size);
long sizecompress = 0;
if (resultCode == Activity.RESULT_OK) {
if (size > SettingsConstant.PIC_SIZE) {
sizecompress = compressImage(tempPhotoPath);
}
sizecompress = sizecompress == 0 ? size : sizecompress;
Log.i("TAG2", "-------2--------压缩大小size:" + size);
// 照片不能大于500kb
if (sizecompress <= SettingsConstant.PIC_SIZE) {
SavePhotoAsyncTask savePhotoAsyncTask = new SavePhotoAsyncTask();
savePhotoAsyncTask.execute(tempPhotoPath);
} else {
// 删除临时图片
FileUtil.deleteFile(tempPhotoPath);
}
} else if (resultCode == Activity.RESULT_CANCELED) {
// 删除临时图片
FileUtil.deleteFile(tempPhotoPath);
}
} else if (requestCode == REQUEST_CODE_INFO) {
finish();
}
super.onActivityResult(requestCode, resultCode, data);
}
//这点是调用系统相机的方法
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0);
try {
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(FileUtil.createFile(photoPath)));
} catch (Exception e) {
e.printStackTrace();
}
startActivityForResult(intent, REQUEST_CODE_CAMERA);
求解???????????????????????????????????