【发布时间】:2014-01-13 06:25:39
【问题描述】:
我有 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。
【问题讨论】:
标签: android image nullpointerexception orientation uri