6
我問這個的原因是因爲文件選擇器Intent
的回調返回Uri
。通過意向如何從InputStream而不是文件獲取Exif數據?
打開文件選擇:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), CHOOSE_IMAGE_REQUEST);
回調:
@Override
public void onActivityResult(int requestCode, int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CHOOSE_IMAGE_REQUEST && resultCode == Activity.RESULT_OK) {
if (data == null) {
// Error
return;
}
Uri fileUri = data.getData();
InputStream in = getContentResolver().openInputStream(fileUri);
// How to determine image orientation through Exif data here?
}
}
一種方式是寫InputStream
到實際File
,但是這似乎是一個不好的解決辦法我。