Version: 2022.2
将 Unity 集成到 Android 应用程序中
Android thread configuration

Deep linking on Android

Deep links are URL links outside of your application that direct users to a location in your application. When the user clicks a deep link for an application, the operating system opens the Unity application at a specified place (for example, a specific scene). For more information about deep links and how to use them, see Deep links.

Enabling deep linking for Android applications

Before you can process deep links, you need to configure your application to react to them. This section contains instructions on how set up deep links for Android.

To enable deep linking for Android applications, use an intent filter. An intent filter overrides the standard Android App Manifest to include a specific intent filter section for Activity. To set up an intent filter:

  1. In the Project window, go to Assets > Plugins > Android.
  2. Create a new file and call it AndroidManifest.xml. Unity automatically processes this file when you build your application.
  3. Copy the following code sample into the new file and save it.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
  <application>
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector" >
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="unitydl" android:host="mylink" />
      </intent-filter>
    </activity>
  </application>
</manifest>

Your Android application now opens when the device processes any link that starts with unitydl://.

Using deep linking on Android

After you enable deep links for Android, the way that you use them is platform-agnostic. For information on how to handle deep links when your application opens, see Using deep links.

将 Unity 集成到 Android 应用程序中
Android thread configuration
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961