java - 如何放置正确的意图参数?
问题描述
我试图制作一个可以查看 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");
但它不起作用。我是否正确传递信息?
解决方案
您不会在任何地方发送任何信息。“3d_only”应该是一些变量,否则你不会发送任何东西。此外,您必须通过执行 String string = getIntent().getStringExtra("mode"); 在另一端检索您的代码。
推荐阅读
- facebook - Facebook App 域与 localhost 一起使用,但不适用于我的网站
- xpath - 替换xpath中的完整字符串刚刚得到
- amazon-web-services - Fargate 上的 AWS docker - 是否可以选择不同的内核?
- google-apps-script - 有没有办法在 Google Drive 上为 Google Web App 托管一个网站图标?
- perl - Perl:复杂数据结构的校验和
- vba - 努力从 VLOOKUP 创建一个带有 MIN 的函数
- python - “分配前引用的局部变量'e'”这个错误是什么意思?如何修复此错误?
- express - 请求的资源上没有“Access-Control-Allow-Origin”标头(express + react/redux)
- swift - 避免两个不同视图之间的触摸手势冲突
- javascript - 根据属性组合数组中的项目并维护引用