我有一张图片的MediaStore.Images.Media.DATA uri,如何使用该uri获取MediaStore.Images.ImageColumns.ORIENTATION? 我得到了一个NullPointerException。
以下是我的代码:
private int getOrientation(Context context, Uri photoUri) {
Log.v("orientatioon", "not crashed01");
Cursor cursor = context.getContentResolver().query(photoUri,
new String[] { MediaStore.Images.ImageColumns._ID,MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null);
Log.v("orientatioon", "not crashed02");
cursor.moveToFirst();
Log.v("orientatioon", "not crashed 03");
int i=cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.ORIENTATION));
Log.v("orientatioon", ""+i);
cursor.close();
return i;
}
我的代码中,在cursor.moveToFirst()这一行出现了NullPointerException
。