An open API service indexing awesome lists of open source software.

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

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

// ...
}
}
```