private UriimageUri;
//跳转相机
private void toCamera() {
File outputImage =new File(Environment.getExternalStorageDirectory(),
TAKE_PHOTO_NAME);
try {
if (outputImage.exists()) {
outputImage.delete();
}
outputImage.createNewFile();
}catch (IOException e) {
e.printStackTrace();
}
if (Build.VERSION.SDK_INT >=24) {
imageUri = FileProvider.getUriForFile(getActivity(),
getContext().getApplicationContext().getPackageName()+".provider", outputImage);
}else {
imageUri = Uri.fromFile(outputImage);
}
//启动相机程序
Intent intent =new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, TakePhotoEnum.TAKE_PICTURE.getRequestCode());
}
case 201:
if (resultCode ==RESULT_OK) {
File file =new File(Environment.getExternalStorageDirectory(), TAKE_PHOTO_NAME);
mListImage.remove(mListImage.size()-1);
mListImage.add(new PostImageBean(file.getAbsolutePath(),file));
mListImage.add(new PostImageBean(""));
mBaseRecyclerAdapter.init(mListImage);
mBaseRecyclerAdapter.notifyDataSetChanged();
}
break;
网友评论