https://github.com/tatsuyafujisaki/android-deep-link-arbitrary-query-sample
Sample of passing arbitrary query parameters using with a deep link to an Android app
https://github.com/tatsuyafujisaki/android-deep-link-arbitrary-query-sample
android deep-link query-string
Last synced: 3 months ago
JSON representation
Sample of passing arbitrary query parameters using with a deep link to an Android app
- Host: GitHub
- URL: https://github.com/tatsuyafujisaki/android-deep-link-arbitrary-query-sample
- Owner: tatsuyafujisaki
- Created: 2020-06-06T13:47:59.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-07T12:38:00.000Z (over 4 years ago)
- Last Synced: 2025-03-24T00:55:35.573Z (3 months ago)
- Topics: android, deep-link, query-string
- Language: Kotlin
- Homepage:
- Size: 171 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How to test deep links
## Option 1
As per [the documentation](https://developer.android.com/training/app-links/deep-linking#testing-filters), run the following from Terminal.
```shell
adb shell am start -a android.intent.action.VIEW -d "https://example.com/?key1=value1&key2=value2"
```
Note that you have to escape `&` to `%26` to pass more than one query parameter.
### Result## Option 2
1. Open Android Studio.
2. Go to Menu bar > `Run` > `Edit Configurations` > `General` tab > `Launch` > `URL`.
3. Put the following in `URL`.
```
https://example.com/?key1=value1&key2=value2
```
4. Run the app.
### Result# How to take an arbitrary query string in fragments
```
The following steps are already done in this sample app.
```
1. Create a navigation graph XML like `res/navigation/nav_graph.xml`.
```xml
```
2. Reference the navigation graph XML in `AndroidManifest.xml`.
```xml
```
3. Add the following in Fragment's `onCreateView()`.
```kotlin
class FirstFragment : Fragment() {
override fun onCreateView(...): View? {
// ...
val queryString = arguments
?.getParcelable(NavController.KEY_DEEP_LINK_INTENT)
?.data
?.encodedQuery// ...
}
}
```