【问题标题】:adding deep linking data to the MainActivity intent-filter removes the icon in the device将深层链接数据添加到 MainActivity 意图过滤器会删除设备中的图标
【发布时间】:2015-07-17 17:34:04
【问题描述】:

我正在尝试向我的应用添加深层链接,当我添加时:

<data android:scheme="http"
                android:host="www.example.com"
                android:pathPrefix="/gizmos" />

对于我的 MainActivity 中的意图过滤器,编译后图标未安装在设备中。

这是清单上的活动部分:

    <activity
        android:name=".MainActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:windowSoftInputMode="adjustPan"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="http"
                android:host="www.example.com"
                android:pathPrefix="/gizmos" />

        </intent-filter>
    </activity>

【问题讨论】:

    标签: android intentfilter deep-linking


    【解决方案1】:

    您需要两个独立的intent-filter

        <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="http"
                        android:host="www.xxx.com"
                        android:pathPrefix="/app" />
        </intent-filter>
    

    【讨论】:

      【解决方案2】:

      Docs说:

      当您想要处理多种意图时,但仅限于 动作、数据和类别类型的特定组合,然后您 需要创建多个意图过滤器。

      因此,您应该定义多个 intent-filters,以便每个 intent-filters 处理一个单独的问题。

      • 一个用于MAIN / LAUNCHER。 (在启动器中显示您应用的图标)

      • VIEW / BROWSEABLE 一个。

      【讨论】:

        猜你喜欢
        • 2015-10-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-02
        • 2014-09-08
        • 1970-01-01
        相关资源
        最近更新 更多