我正在尝试显示通过存储的相机意图(触发内置相机应用程序)捕获的图片external SD-card.
文件路径和文件名存储在String变量中'mCurrentPhotoPath'.
我已经验证捕获的图像存储在'mCurrentPhotoPath'使用ES File Explorerapp 指定的位置,但BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions)始终返回FileNotFoundException.这是我存储捕获图像的代码:
private void addPicToGallery() {
File f = new File(mCurrentPhotoPath);
//for debug purpose only
Log.i(MYTAG, "value of mCurrentPhotoPath in addPicToGallery: " +mCurrentPhotoPath);
Log.i(MYTAG, "value of f in addPicToGallery: " +f);
Uri contentUri = Uri.fromFile(f);
//for debug only
Log.i(MYTAG, "value of contentUri in addPicToGallery: " +contentUri);
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
mediaScanIntent.setData(contentUri);
sendBroadcast(mediaScanIntent);
}
Run Code Online (Sandbox Code Playgroud)
解码缩放图像的代码,用于显示ImageView:
private void setFullImageFromFilePath() {
Log.i(MYTAG, …Run Code Online (Sandbox Code Playgroud)