Dr jonge
Dr jonge

Reputation: 11

How to use deepLink in Android

PLEASE HELP MEEEE

In my application i want use DeepLink and for this i write below code.
But when run application not suggest my application and just show in Chrome browser !

My Url : sosapp://sosapp/hashcode/ghfhgfhgf?

My codes :

<activity
    android:name=".Activity.LandingActivity"
    android:screenOrientation="sensorPortrait" />
<activity
    android:name=".Activity.MainActivity"
    android:screenOrientation="sensorPortrait">

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="sosapp" android:host="sosapp"/>
    </intent-filter>

</activity>

How can i fix it and when click on this Url from mobile, suggest my app ?

Upvotes: 1

Views: 2155

Answers (3)

Caique Oliveira
Caique Oliveira

Reputation: 262

I have tried use your link in my Activity and works fine.

my Activity Manifest:

<activity android:name=".MyActivity">
        <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="sosapp"
                android:scheme="sosapp" />
        </intent-filter>
    </activity>

and my intent used to call the activity

val action = Intent() 
action.data = Uri.parse("sosapp://sosapp/hashcode/ghfhgfhgf?")
startActivity(action)

Upvotes: 1

Rainmaker
Rainmaker

Reputation: 11110

Try adding label, it's mandatory for higher versions of android. See example from the docs. They always include a label for intent-filter

  <intent-filter android:label="@string/filter_view_example_gizmos">
        <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>

Upvotes: 0

salmanseifian
salmanseifian

Reputation: 1082

Add pathPattern to your data tag like below:

  <data
                android:host="sosapp"
                android:pathPattern="/*"
                android:scheme="sosapp" />

Upvotes: 0

Related Questions