捕获图像光标在android中返回null

时间:2015-03-13 06:05:25

标签: android cursor image-capture

在应用程序中我使用cursorloader获取捕获图像文件路径,它总是返回null

Uri file path = file:///storage/emulated/0/Pictures/BBI_Images/BBI_ORIG_20150313_112912.jpg

public static int getRotation(Context context, Uri selectedImage, String filePath) {
        try{
        String[] projection = { MediaStore.Images.Media.DATE };

        CursorLoader loader = new CursorLoader(context, selectedImage, projection, null, null, null);
        Cursor cursor = loader.loadInBackground();//here i can get only null
        cursor.moveToFirst();

        int column_index_data = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);

        int rotation = 0;
        String realPath = cursor.getString(column_index_data);
        if (realPath != null) {
            rotation = getRotationForImage(realPath);
        }
        return rotation;
        }catch(Exception e){
          e.printStackTrace();  
        }
        return 0;
    }

0 个答案:

没有答案