我正在尝试让cameraFragment.this
在Fragment中工作,但它一直告诉我“错误的第一个参数类型等”
public void dispatchPicTaken(){
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if(intent.resolveActivity(getActivity().getPackageManager()) !=
null){
File imgFile = null;
imgFile = createPhotoFile();
if(imgFile != null) {
pathToFile = imgFile.getAbsolutePath();
Uri photoURI =
FileProvider.getUriForFile(cameraFragment.this, "test", imgFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(intent, 1);
}
}
}
答案 0 :(得分:0)
您应该使用getActivity()
而不是fragment
来获取cameraFragment.this
中的上下文
FileProvider.getUriForFile(getActivity(), "test", imgFile);