简体   繁体   中英

Android deep linking, cannot filter intent with scheme 'android-app'

I'm following the App Indexing API doc . My app URI is android-app://com.mypackagename.app/intro/intro/ , so I add this to the manifest file, under <activity>

<activity
            android:name=".MainActivity"
            android:label="@string/config_app_name"
            android:screenOrientation="portrait"
            android:enabled="true"
            android:exported="true"
            > 
            <intent-filter android:label="test">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="android-app"
                    android:host="com.mypackagename.app" />
            </intent-filter>
</activity>

But when go and test my deep link as said in Test your deep link on my phone, the link android-app://com.mypackagename.app/intro/intro/ can't be opened, there's a toast saying "there are no apps installed that can handle it"

What am I missing? Thanks

Update: in the documentation pointed out by Mattia, there's definitely an option to put whatever scheme, like 'example', but it doesn't work for me. I'm on Lollipop, if it makes a difference.

<intent-filter android:label="@string/filter_title_viewgizmos">
         <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 "example://gizmos" -->
         <data android:scheme="example"
               android:host="gizmos" />
     </intent-filter>

Update 2 : anything after the package is the scheme, in my case, android-app://com.mypackagename.app/intro/intro/ , it is intro . Marked answer below

You should use your domain, not android-app and your package as you can see in the documentation .

Try this example:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.test">

    <application
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:windowSoftInputMode="stateVisible">
            <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:host="yourdomain"
                    android:scheme="example" />
            </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:host="www.yourdomain.com"
                    android:scheme="http" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Than test here with these values (change com.example.test with the package name of your app):

android-app://com.example.test/http/www.yourdomain.com/page
android-app://com.example.test/example/yourdomain/page

When you scan the bar code and press the link, your app will open automatically.

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