I have an Activity that handles image files:
if (Intent.ACTION_VIEW.equals(action) && type != null && type.startsWith("image/")) {
Uri imageUri = i.getData();
try {
Bitmap image = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri);
} catch (Exception e) {
e.printStackTrace();
}
}
This gets me the image in the bitmap, however I also need to get exif data from it. Saving the image using image.compress
removes this data.
If I click View
in gmail for example, there is no real path that I can use, so I'm stuck at trying to get the exif data. Is there a way to get a byte[]
of the data passed into my activity, or get the exif data from a Bitmap
object?
Note:
This:
ExifInterface exifData = new ExifInterface(imageUri.getPath());
Does not cause an exception, however I get null for all the tags, and if I try to print the path, I get this:
/my.email@gmail.com/messages/248/attachments/0.1/BEST/false
If I first hit save
and then view
in gmail, I can successfully retrieve the exif data with the above method, passing imageUri.getPath()
to an exif constructor.
If there is no way to make view
work, then how can I make it so the user is prompted to use my application only after saving the file to disk? This is how my intent filters look like right now:
<activity android:name=".GameActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>