我正在尝试让cameraFragment.this
在片段中工作,但它一直告诉我“错误的第一个参数类型等”
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);
}
}
}
最佳答案
您应该使用getActivity()
在fragment
而不是cameraFragment.this
中获取上下文
FileProvider.getUriForFile(getActivity(), "test", imgFile);
关于java - 第一个参数类型Uri/FileProvider fragment 错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56402866/