3

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

EyeQ Tech
  • 7,198
  • 18
  • 72
  • 126
  • What happens when you try to open an url like android-app://com.mypackagename.app? Does it succeed? – Edson Menegatti May 04 '15 at 19:45
  • @EdsonMenegatti you mean in the browser on mobile? It's just a google search for my app package name, doesn't seem to be 'deep-linked' to anything – EyeQ Tech May 05 '15 at 05:25

1 Answers1

5

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.

Mattia Maestrini
  • 32,270
  • 15
  • 87
  • 94
  • thanks, but your example doesn't work, it still says "there's no app installed'. In the link you posted, there's the custom scheme 'example', updated my question above. – EyeQ Tech May 05 '15 at 05:14
  • I just updated my answer with the 'example' scheme. Now it works with both of deep link type. Please check that you have the [Google app](https://play.google.com/store/apps/details?id=com.google.android.googlequicksearchbox) installed and updated. – Mattia Maestrini May 05 '15 at 05:47
  • thanks, stupid me, I thought the scheme is the text before ://, so I put `android-app` as scheme – EyeQ Tech May 05 '15 at 08:44