0

I am trying to build an application where if I click the link my app(if installed) will open.But it's not working,don't know why.It's always redirecting to google.com

My manifest file

<activity   android:name=".DeeplinkingActivity"
            android:label="@string/app_name"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@android:style/Theme.Holo.NoActionBar">
            <intent-filter android:label="@string/app_name">
                <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://example.com/soham" -->
                <data android:scheme="http"
                    android:host="example.com"
                    android:pathPrefix="/soham" />
                <data android:scheme="http"
                    android:host="www.example.com"
                    android:pathPrefix="/soham" />
            </intent-filter>
        </activity> 

My test.html

<a href="intent://scan/#Intent;scheme=http;package=soham.com.deeplinking;S.browser_fallback_url=http%3A%2F%2Fgoogle.com;end"></a>

I think the problem is in the html file.Any help?

Soham
  • 4,397
  • 11
  • 43
  • 71

2 Answers2

1

Your link is incorrect, you are using the host of the Android Intents with Chrome example. You need to use the host and pathPrefix configured in the AndroidManifest.xml.

Your host is example.com and your pathPrefix is /soham, the link will become:

<a href="intent://example.com/soham#Intent;scheme=http;package=soham.com.deeplinking;S.browser_fallback_url=http%3A%2F%2Fgoogle.com;end">Deeplink</a>
Mattia Maestrini
  • 32,270
  • 15
  • 87
  • 94
  • Thanks.It's working now.Can you tell me about how to send parameters through the link.Suppose I have to send id =1,2. – Soham Oct 19 '15 at 13:16
  • You're welcome. [This answer](http://stackoverflow.com/a/21304773/2837959) explains in detail how to pass arguments as extras to the App. – Mattia Maestrini Oct 19 '15 at 13:21
0

Try this: This is working for my app:

NOTE: write below code within your launcher activity tag

<intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter android:label="@string/app_name" >
            <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://WRITE YOUR HOST NAME” -->
            <data
                android:host="index.html"
                android:scheme="WRITE YOUR HOST NAME" />
        </intent-filter>
        <intent-filter android:label="@string/app_name" >
            <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://example.com/WRITE YOUR HOST NAME” -->
            <data
                android:host="WRITE YOUR HOST NAME.com"
                android:pathPrefix="/index.html"
                android:scheme="http" />
        </intent-filter>
        <intent-filter android:label="@string/app_name" >
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="WRITE YOUR HOST NAME" />
        </intent-filter>
  • This is sample app,not in the playstore,don't have any website.So what should be the android:scheme and android:host – Soham Oct 19 '15 at 12:00