[英]Wrong 1st argument Type Uri/FileProvider Fragment
我正試圖讓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.