首页 > 解决方案 > 如何放置正确的意图参数?

问题描述

我试图制作一个可以查看 3d 模型的 SceneView 意图。

   Intent sceneViewerIntent = new Intent(Intent.ACTION_VIEW);
    sceneViewerIntent.setData(Uri.parse("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Avocado/glTF/Avocado.gltf"));
    sceneViewerIntent.setPackage("com.google.android.googlequicksearchbox");
    sceneViewerIntent.putExtra("mode","3d_only");
    mContext.startActivity(sceneViewerIntent);

当此意图打开时,它为用户提供了在您自己的环境中查看模型的选项,但我想关闭它并根据https://developers.google.com/ar/develop/java/scene-viewer# 3d-or-ar您应该能够传递一个名为“mode”的参数,该参数的值可以是“3d_only”,这应该会阻止用户在 AR 中查看模型。

我试图通过传递这个值,sceneViewerIntent.putExtra("mode","3d_only");但它不起作用。我是否正确传递信息?

标签: javaandroid-intentarcoresceneform

解决方案


您不会在任何地方发送任何信息。“3d_only”应该是一些变量,否则你不会发送任何东西。此外,您必须通过执行 String string = getIntent().getStringExtra("mode"); 在另一端检索您的代码。


推荐阅读