[英]Wrong 1st argument Type Uri/FileProvider Fragment
I'm trying to get cameraFragment.this
to work in a Fragment but it keeps telling me "Wrong 1st argument type etc" 我正试图让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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.