Google PanoramaAPI stopped working on Android 11

120 views Asked by At

I have a working implementation of Googles PanoramaAPI in my Application. Unfortunately, the implementation stopped working on Android 11.

The implementation looks like the following:

Uri uri = Uri.fromFile(file);
Panorama.PanoramaApi.loadPanoramaInfoAndGrantAccess(mClient, uri).setResultCallback(
        new ResultCallback<PanoramaResult>() {
            @Override
            public void onResult(PanoramaResult result) {
                if (result.getStatus().isSuccess()) {
                    Intent viewerIntent = result.getViewerIntent();
                    Log.i(TAG, "found viewerIntent: " + viewerIntent);
                    if (viewerIntent != null) {
                        startActivity(viewerIntent);
                        finish();
                    }
                } else {
                    Log.e(TAG, "error: " + result);
                }
            }
        });

Following Situation:

  • When I make a panorama image on my smartphone and load it into the given implementation, it works. The image get's loaded from /storage/emulated/0/DCIM/Camera/*.jpg and the panorama view is shown without a problem.
  • When I Upload the same image on a server and download it through the app, the image get's stored on /storage/emulated/0/Android/data/<applicationId>/files/*.jpg. Unfortunately, the panorama view is not able to load the image and the viewerIntent is allways null.

For me, it looks like a permission problem on Android 11, but I don't know how to fix it. I don't want to download the image into a more public area of the phone. Does anyone has an idea how to fix it?

1

There are 1 answers

0
qtfw On

I suspect it is related to the introduction of Scoped Storage in Android 11, but I'm not sure.

I've managed to put together an alternative to the Panorama API using the VR Kit, which I've documented in my blog post with some code snippets.

The TLDR is this:

  1. Replace your original ImageView with a VrPanoramaView
  2. Use the VrPanoramaView's API to hide some options (optional)
  3. Overlay an image button over the VrPanoramaView and use it to toggle between gyroscopic and touch modes
  4. Use touch interception to support pinch zoom (this will be in a separate blog post)
  5. Load your image into VrPanoramaView