Question

I'm currently working on an application to facilitate sharing Panorama and Photosphere images from Android's Gallery application.

My understanding is that Panorama images have a reported mimetype of application/vnd.google.panorama360+jpg (source: https://developers.google.com/photo-sphere/android/?hl=en), and therefore, the following snippet of my AndroidManifest.xml should be adequate to allow photospheres to be shared to my activity from the Gallery application:

<activity
    android:name=".SphereUploadActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait">

    <intent-filter>
        <data android:mimeType="application/vnd.google.panorama360+jpg" />
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

This works fine on my own device (Nexus 5, Android 4.4.2), displaying my application in the sharing menu for 360° Panorama images. On any other device I test on though, my application never appears (I've tested on an identical Nexus 5, a Nexus 4, and a Nexus 7 tablet). I'm definitely trying to share panorama images each time, and I've tried reinstalling, clearing app data, restarting devices - everything but a factory reset to try and get it either breaking on my device, or fixed on others.

During my testing, I have also tried relaxing my mime type restriction to only filter for image/*. Weirdly, this causes my application to always display in the share menu, on all devices, and it works fine, except for displaying as an option for all images, and not just panoramas. Since my application is intended to handle just photospheres, I'd obviously rather not have my application listed as a share option for regular photos.

One other thing I have tried is logging the mime type of the URI I receive in my activity. I ran this with the relaxed intent filter I have described above so that I could test on all the devices I have available, using the following code in my SphereViewActivity:

Uri imageUri = (Uri) getIntent().getExtras().get(Intent.EXTRA_STREAM);
Log.d("PANO MIME TYPE", getContentResolver().getType(imageUri);

Weirdly, this always logs image/jpeg, no matter what device I'm on, including when I test on the working device with the panorama-only mime type intent-filter enabled and the generic image one disabled. I would expect in this case at least, that it should report as the correct panorama mime type.

I've done a bunch of research, both here on StackOverflow, and across a few other sites. I've found Christopher Orr's blog post on photosphere mime types useful for validating that I'm using the correct intent filter in my manifest, but not helpful for this specific problem. All of the other problems I've come across have been intent filter manifest problems that have been easily resolved - I've not come across anyone with the same problem as I seem to have. I've also had a skim through the source for the Gallery2 application in the Android platform package source code, but didn't find anything useful - it looked to me like the panorama was being shared in the normal way with nothing different going on.

So, I'm more or less out of ideas here - any suggestions will be greatly appreciated!

Was it helpful?

Solution

After extensive logging and debugging, I found that the problem was that the Camera application will only report a Photo Shere image with the Sphere mimetype if it is of a sufficient size to require special rendering. That is, if just one or two frames are captured in Photo Sphere mode, the image will have a mime type of image/jpeg, but if a full sphere is captured, the mime type will be correctly reported as application/vnd.google.panorama360+jpg.

I'm unsure as to whether this behaviour is a bug with the Camera application or not, since it appears to be making a logical decision as to whether an image is actually a photo sphere based on the area that the capture encompasses. Regardless of the mime type, the XMP photo meta data as described by Google is available and can be parsed from the image.

For my particular application, I ended up having to accept either image/jpeg or application/vnd.google.panorama360+jpg images. I then have an asynctask parse the XMP data from the image to detect whether it has the necessary Photo Sphere metadata or not, and act accordingly (exiting with a Toast message if the metadata is not present).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top