Deep Linking — Setup for Android
This Part is for setting up DeepLink, this time for Android. I have written a post on how to set up Deep Link on iOS, and you can find the page here.
Setting up a deep link on android is very simple; you can do it manually or through the command.
Setup using command
To configure the external linking in Android, you can create a new intent in the manifest. The easiest way to do this is with the uri-scheme
package:
npx uri-scheme add jlrecharge --android
RESULTED:
jalves@Justimianos-MacBook-Pro jlrecharge % npx uri-scheme add jlrecharge --android
› Android: Added URI protocol "jlrecharge" to project
jalves@Justimianos-MacBook-Pro jlrecharge %
Setup Manually
If you want to add it manually, open up SimpleApp/android/app/src/main/AndroidManifest.xml
, and make the following adjustments:
- Set
launchMode
ofMainActivity
tosingleTask
to receive intent on existingMainActivity
(this is the default, so you may not need actually to change anything). - Add the new
intent-filter
inside theMainActivity
entry with aVIEW
type action:
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</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:scheme="jlrecharge"/>
</intent-filter>
</activity>
Validate the Deep Linking
The adb
command can be used as follows to test deep links with the Android emulator or a connected device:
adb shell am start -W -a android.intent.action.VIEW -d [your deep link] [your android package name]
For example:
adb shell am start -W -a android.intent.action.VIEW -d "jlrecharge://home" com.jlrecharge.dev
For Support or if you have any questions, please reach out.
If you have questions or need help, reach out — info@jaalves.com.
Collaboration:
DM on Instagram : https://www.instagram.com/jaa.consulting/
DM on Facebook: https://www.facebook.com/Jaa.Consulting.Official