0
我試圖獲取URI的圖像位圖,但它給了我以下錯誤。從uri獲取位圖時獲取文件未發現異常
System.err的(3102):java.io.FileNotFoundException:沒有內容提供商:/storage/emulated/0/1.jpg
我試圖代碼,
Cursor mCursor;
mCursor=activity.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,mProjection,null, null, MediaStore.Images.Media.DEFAULT_SORT_ORDER);
if (mCursor != null) {
mCursor.moveToFirst();
do {
String strPath = mCursor.getString(mCursor
.getColumnIndex(MediaStore.Images.Media.DATA));
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(
activity.getContentResolver(), Uri.parse(strPath));
//Here i'm using bitmap
} catch (FileNotFoundException e) {
Log.i("Exception",
"Image file not found: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
Log.i("Exception",
"Input Output Failure: " + e.getMessage());
e.printStackTrace();
}
} while (mCursor.moveToNext());
看一看這個問題>>> http://stackoverflow.com/questions/20067508/get-real-path-from-uri-android -kitkat - 新的存儲訪問框架 – 2Dee