5

I was going through the document http://developer.android.com/training/app-indexing/deep-linking.html to learn about deeplinking in Android. I have an activity in my Android app called WalletActivity and I have managed to successfully create deeplink for that by making necessary changes in the AndroidManifest file.

But, my WalletActivity contains a list of options, tapping on which it lands me to another activity WalletRechargeActivity, the contents of which depends on the respective option that is selected from the list of options in WalletActivity. Now, I want a deeplink that can land me directly on the respective WalletRechargeActivity screen itself. How do I do that?

For example, if example://wallet lands me to WalletActivity, I would like something like example://wallet/abcd50 to land me to the respective WalletRechargeActivity screen with the $50 recharge option. And this value abcd50 can vary from anything to anything, and is not fixed from beforehand, so I cannot add it in the AndroidManifest file with respect to the WalletRechargeActivity either, right? I need to handle it dynamically. So, can you tell me how do I do this?

Sanjiban Bairagya
  • 704
  • 2
  • 12
  • 33
  • https://github.com/airbnb/DeepLinkDispatch allows for declarative, annotation-based API to declare application deep links, check it out. – Morse Apr 02 '16 at 09:59
  • Simply register a prefix pattern (wallet/*) instead and parse the prefix in your WalletRechargeActivity. – Simon Marquis Apr 02 '16 at 11:14

1 Answers1

-1

Here is a sample code to route the user to WalletActivity or WalletRechargeActivity. You can then use the getIntent().getData() method to parse the url content.

<activity android:name=".WalletActivity">
    <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="example" />

        <data android:host="wallet" />
    </intent-filter>
</activity>
<activity android:name=".WalletRechargeActivity">
    <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="example" />

        <data android:host="wallet" />

        <data android:pathPattern="/..*" />
    </intent-filter>
</activity>
Simon Marquis
  • 7,248
  • 1
  • 28
  • 43