首页 > 解决方案 > Google PanoramaAPI 停止在 Android 11 上运行

问题描述

我的应用程序中有 Googles PanoramaAPI 的工作实现。不幸的是,该实现在 Android 11 上停止运行。

实现如下所示:

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);
                }
            }
        });

以下情况:

对我来说,这看起来像是 Android 11 上的权限问题,但我不知道如何解决。我不想将图像下载到手机的更公共区域。有谁知道如何解决它?

标签: androidpanoramasandroid-11

解决方案


我怀疑这与 Android 11 中引入Scoped Storage有关,但我不确定。

我已经设法使用 VR Kit 组合了 Panorama API 的替代方案,我已经在我的博客文章中记录了一些代码片段。

TLDR 是这样的:

  1. 将您的原件替换ImageViewVrPanoramaView
  2. 使用VrPanoramaView的 API 隐藏一些选项(可选)
  3. 在 上覆盖图像按钮VrPanoramaView并使用它在陀螺仪和触摸模式之间切换
  4. 使用触摸拦截来支持捏缩放(这将在单独的博客文章中)
  5. 将图像加载到VrPanoramaView

推荐阅读