Anil Kanani
Anil Kanani

Reputation: 1

how to add deep-linking in android app?

please tell me Intent filter in Manifest file for deep linking.

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:host="packagename"
                android:scheme="android-app" />
        </intent-filter> 

Upvotes: 0

Views: 608

Answers (1)

Robert Estivill
Robert Estivill

Reputation: 12477

I would probably go for a library like DeepLinkDispatch, which simplifies the setup and maintenance of the deep links configuration.

From the README.md

@DeepLink("foo://example.com/deepLink/{id}")
public class MainActivity extends Activity {

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getIntent().getBooleanExtra(DeepLink.IS_DEEP_LINK, false)) {
       Bundle parameters = getIntent().getExtras();
       String idString = parameters.getString("id");
       // Do something with the ID...
    }
  }
}

And does not contaminate your manifest as only one Activity is declare

<activity
    android:name="com.airbnb.deeplinkdispatch.DeepLinkActivity"
    android:theme="@android:style/Theme.NoDisplay">
    <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="airbnb" />
    </intent-filter>
 </activity>

Upvotes: 1

Related Questions