【问题标题】:How to start an Unity App with an Intent from another App?如何使用来自另一个应用程序的 Intent 启动一个 Unity 应用程序?
【发布时间】:2020-02-17 09:34:29
【问题描述】:

我尝试使用一些允许我创建意图的测试应用程序打开应用程序。但这不起作用,也不适用于我的代码。我对问题根源的猜测是 Unity 生成的清单文件。导出了 2 个项目,对 adb 等可见的包名在此清单中。

<?xml version="1.0" encoding="utf-8"?>
<!-- GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.app" xmlns:tools="http://schemas.android.com/tools" android:installLocation="preferExternal">
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <application android:label="@string/app_name" android:icon="@mipmap/app_icon" />
</manifest>

此清单没有意图过滤器,并且由于此项目中没有活动,我不确定如何添加。我认为我需要一个意图过滤器来使来自我的应用程序外部的意图调用工作。有没有人解决过这个问题或知道如何解决它?

另一个清单看起来像这样,但有一个通用的包名称,从外部 (adb) 也是不可见的。但是这个有一个意图过滤器。但我很确定,我无法有意访问它。

<?xml version="1.0" encoding="utf-8"?>
<!-- GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" xmlns:tools="http://schemas.android.com/tools">
  <application>
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector" android:screenOrientation="fullSensor" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
      <meta-data android:name="android.notch_support" android:value="true" />
    </activity>
    <meta-data android:name="unity.splash-mode" android:value="0" />
    <meta-data android:name="unity.splash-enable" android:value="True" />
    <meta-data android:name="notch.config" android:value="portrait|landscape" />
    <meta-data android:name="unity.build-id" android:value="f5abdf68-b589-4d67-acb2-5c55e15b3fd3" />
  </application>
  <uses-feature android:glEsVersion="0x00030000" />
  <uses-feature android:name="android.hardware.vulkan.version" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>

【问题讨论】:

    标签: java android unity3d android-intent intentfilter


    【解决方案1】:

    如果这是 temp->staging area 文件夹中的 android manifest 并且你修改它.. 它不会工作。因为每次构建时,统一都会创建一个新的 android 清单。而是在 Plugins->Android 文件夹中创建一个 android manifest 文件并创建 intent-filter,unity 会自动合并 2 个 android manifest。

    并确保您对具有 VIEW 数据的第二个意图过滤器进行了修改。添加类似 android:scheme(im on mobile and just google it and you will find it) 和你的意图等内容。

    【讨论】:

    • 感谢您的回复!这是生成的清单,我导出了项目以检查它是否正确。如果我理解正确,您认为我要提交数据吗?因为我不想这样做,我只想从另一个应用程序启动我的统一应用程序。
    • 是的,我明白了...要做到这一点,您只需要在 Plugins-> Android 文件夹中的新 android 清单中的应用程序方案。您可以使用 app:// 触发应用程序,然后意图将继续。看看您是否可以点击此链接 - connect.unity.com/p/deep-linking-on-android-ios-with-unity
    【解决方案2】:

    请在此处查看答案,我也花了一段时间,但我想通了:https://stackoverflow.com/a/65092095/1828990

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多