FileNotFoundException when Using ExifInterface

后端 未结 1 1362
日久生厌
日久生厌 2021-01-20 20:25

I have been uploading images to FirebaseStorage, but often they are the wrong way around when displaying them. I have discovered the ExifInterface that can determined the or

相关标签:
1条回答
  • 2021-01-20 20:55

    A Uri is not a File.

    Step #1: Delete File file = new File(uri.toString());

    Step #2: Make sure that you are using the Support Library edition of ExifInterface

    Step #3: Call getContentResolver() on your Activity to get a ContentResolver

    Step #4: Call openInputStream() on the ContentResolver, passing in the Uri, to get an InputStream on the content pointed to by that Uri

    Step #5: Pass that InputStream to the ExifInterface constructor

    Step #6: Use that ExifInterface as you are presently, to determine the image orientation

    Step #7: Once you get things working, move all of this I/O to a background thread

    0 讨论(0)
提交回复
热议问题