Mastering Android Deep Linking with Multiple Query Parameters

Mastering Android Deep Linking with Multiple Query Parameters

22 April 2024 Stephan Petzl Leave a comment Tech-Help

Deep linking allows applications to be opened not just from the icon, but from hyperlinks, providing a seamless user experience akin to navigating the web. For developers working with Android applications, setting up deep linking with multiple query parameters can be a bit tricky. This article will guide you through the process, ensuring that you can test your deep links effectively.

Firstly, you need to declare the intent filters for your activity in the AndroidManifest.xml. Here is a snippet to illustrate how this is done:

    <activity
        android:name=".ui.activities.MyActivity"
        android:label="@string/title_activity"
        android:screenOrientation="portrait">
        <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:host="myHost"
                android:scheme="myCustomScheme" />
        </intent-filter>
    </activity>
  

Once you’ve set up your manifest, you’ll want to test the deep link. The Android Debug Bridge (ADB) is a versatile command-line tool that lets you communicate with an emulator instance or connected Android device. Here’s how you can test your deep links with multiple query parameters using ADB:

Escaping the Ampersand

To test deep links that include multiple query parameters, you will need to escape the ampersand (&) character in the ADB command. This is because the ampersand is a special character in many command-line environments, used to run multiple commands on a single line. Here is the command you should use:

    adb shell am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key=category_parent_id\&value=92\&title=test" com.myApp.android
  

Using Single Quotes

Alternatively, you can encapsulate the entire command within single quotes to avoid having to escape special characters:

    adb shell 'am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key=category_parent_id&value=92&title=test" com.myApp.android'
  

While ADB is a powerful tool, it can be cumbersome to use for repetitive testing tasks. This is where Repeato comes in. Repeato is a no-code test automation tool that simplifies the process of creating, running, and maintaining automated tests for your Android and iOS apps.

With its intuitive interface and AI-powered computer vision capabilities, Repeato can help you automate the testing of deep links among other features, without the need to write complex scripts. The ability to execute ADB commands directly through Repeato’s script steps further enhances its functionality, making it an ideal solution for developers looking to streamline their testing workflow.

Conclusion

Testing deep links with multiple query parameters is essential for ensuring a seamless user experience. By using the correct ADB command syntax or taking advantage of Repeato’s user-friendly test automation capabilities, you can efficiently validate deep linking behavior in your Android applications.

Like this article? there’s more where that came from!