简体   繁体   中英

Android intent data host not using the whole URI host

When using an intent filter to allow opening certain links from the app like this:

      <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"/>
        <data android:scheme="https"/>
        <data android:scheme="custom-scheme"/>
        <data android:host="app.dev.example.com"/>
      </intent-filter>

The application still proposes to open a link dev.example.com with the app. It is like it is ignoring the starting portion of the host.

Is there a way to only allow app.dev.example.com/... and not dev.example.com/... or example.com/... ?

The whole manifest:

<manifest package="com.e.axamplepp"
  xmlns:android="http://schemas.android.com/apk/res/android">
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

  <application android:label="@string/app_name" android:icon="@mipmap/launcher_icon">
    <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">

      <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme"/>
      <meta-data android:name="flutter_deeplinking_enabled" android:value="true"/>
      <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"/>
        <data android:scheme="https"/>
        <data android:scheme="custom-scheme"/>
        <data android:host="app.dev.example.com"/>
      </intent-filter>

    </activity>

    <meta-data android:name="flutterEmbedding" android:value="2"/>
  </application>

  <queries>
    <intent>
      <action android:name="android.intent.action.VIEW"/>
      <data android:scheme="https"/>
    </intent>
  </queries>
</manifest>

make sure your intent filter have action, category

 <intent-filter android:label="@string/example">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- Accepts URIs that begin with "http://www.example.com/test” -->
    <data android:scheme="http"
          android:host="www.example.com"
          android:pathPrefix="/test" />
    <!-- note that the leading "/" is required for pathPrefix-->
</intent-filter>

more details refer Deep linking

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM