0
我得到︰android.os.FileUriExposedException。相機不適用於安卓7.0
When targeting Android N, file:// URIs are not allowed anymore. I know We should use content:// URIs instead. However, my app needs file for both image and video. Any ideas?
mMediaUri = Uri.fromFile(new File(AppHelper.getDirectoryPath(),AppHelper.getFileName() + ".jpeg"));
Intent iCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
iCamera.putExtra(MediaStore.EXTRA_OUTPUT, mMediaUri);
startActivityForResult(iCamera, Constants.INTENT_CALL.CAPTURE_IMAGE);
和onActivityResult
case Constants.INTENT_CALL.CAPTURE_IMAGE:
String filePath=SiliCompressor.with(getActivity()).compress(mMediaUri.toString(), true);
Please add sample code...if Available.
有你請求在r處使用相機的許可不定時? – magicleon
https://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed https://github.com/commonsguy/cw-omnibus/tree/master/相機/ FileProvider https://github.com/commonsguy/cw-omnibus/tree/master/Media/VideoRecordIntent – CommonsWare
是我已經添加了運行時權限....只針對Android N給android.os.FileUriExposedException ... –