We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All

APP Ability Development Guide

The APP Ability takes you to a specific destination within an app or an RPK through a deep link, which is triggered upon a simple click.

Deep Linking is realized through a URI Scheme.

1.1 What can be achieved through Deep Linking?

  1. Launch the designated app, transfer data to it, and display details about specific content based on the transferred data.

  2. Trigger the designated app and jump straight to a specific screen in the app with a URL link.

  3. Connect apps together so that they are not isolated from each other.

  4. Optimize user experience, which is the ultimate goal.

1.2 Official Introduction

When a clicked link or programmatic request invokes a Web URI intent, the Android system tries each of the following actions, in sequential order, until the request succeeds:

  1. Open the user’s preferred app that can handle the URI, if one is designated.

  2. Open the only available app that can handle the URI.

  3. Allow the user to select an app from a dialog.

Official introduction is available at: https://developer.android.com/training/app-links/deep-linking

2. URL Scheme Format

2.1. URL Scheme Format

  1. scheme://host/path:port/path?query1=xxxx&query2=xxxx
  2. For example:
  3. deeplinkapp://com.mytest.deeplink:8080/deeplinkDetail?param1=test

It comprises scheme, host, port, path, and query.

deeplinkapp: Indicates the Scheme name. (scheme)

com.mytest.deeplink: Indicates the address to which the Scheme applies. (host)

8080: Indicates the port number. (port)

deeplinkDetail: Indicates the page as specified by the Scheme. (path)

param1: Indicates the name of the transferred parameter. (query)

3.1 Modifying the Manifest File

We need to add, in the manifest file, an intent filter to the activity to be opened to external parties. See the following for the configuration:

  1. <activity
  2. android:name=".******Activity">
  3. <intent-filter>
  4. <!--The following are mandatory-->
  5. <action android:name="android.intent.action.VIEW" />
  6. <category android:name="android.intent.category.DEFAULT" />
  7. <category android:name="android.intent.category.BROWSABLE" />
  8. <!--The URL Scheme, which may be configured as needed-->
  9. <data
  10. android:scheme="****" <!--For example android:scheme="deeplinkapp"-->
  11. android:host="****" <!--For example android:host="com.mytest.deeplink"-->
  12. android:port="****" <!--For example android:port="8080" -->
  13. android:path="****" <!--For example android:path="deeplinkDetail" -->
  14. />
  15. </intent-filter>
  16. </activity>

3.2 Logic Processing Codes

Add logic processing codes to the activity. Do as follows:

  1. if (getIntent() != null && getIntent().getData() != null)
  2. {
  3. Uri uri = getIntent().getData();
  4. if (uri != null) {
  5. //Complete URL information
  6. String url = uri.toString();
  7. //scheme
  8. String scheme = uri.getScheme();
  9. //host
  10. String host = uri.getHost();
  11. //port
  12. int port = uri.getPort();
  13. //path
  14. String path = uri.getPath();
  15. //query
  16. String query = uri.getQuery();
  17. //Obtain the value of the specified parameter
  18. String param1= uri.getQueryParameter("param1");
  19. }
  20. }

4.Test

4.1 Running the adb Command

  1. $ adb shell am start -a android.intent.action.VIEW –d
  2. For example:
  3. adb shell am start -a android.intent.action.VIEW –d deeplinkapp://com.mytest.deeplink:8080/deeplinkDetail?
  4. param1=test com.mytest.deeplink

4.2 Opening the URL from Web Browser

For details, see the Example.

  1. Replace the deeplink address in the deep link.html file, copy the file to your mobile phone, and open the HTML file from your web browser.
  2. <a href="deeplinkapp://com.mytest.deeplink:8080/deeplinkDetail?param1=test">Open APP</a>

1.Check with your product manager or the R&D that the app page supports deep link already.
Deep link format: [scheme]://[host]/[path]?[query]

2.Obtain the AndroidManifest file of the app and find the activity configuration for the corresponding page.

Example:

  1. <activity
  2. android:name="com.example.android.GizmosActivity"
  3. android:label="@string/title_gizmos" >
  4. <intent-filter android:label="@string/filter_view_http_gizmos">
  5. <action android:name="android.intent.action.VIEW" />
  6. <category android:name="android.intent.category.DEFAULT" />
  7. <category android:name="android.intent.category.BROWSABLE" />
  8. <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
  9. <data android:scheme="http"
  10. android:host="www.example.com"
  11. android:pathPrefix="/gizmos" />
  12. <!-- note that the leading "/" is required for pathPrefix-->
  13. </intent-filter>
  14. <intent-filter android:label="@string/filter_view_example_gizmos">
  15. <action android:name="android.intent.action.VIEW" />
  16. <category android:name="android.intent.category.DEFAULT" />
  17. <category android:name="android.intent.category.BROWSABLE" />
  18. <!-- Accepts URIs that begin with "example://gizmos” -->
  19. <data android:scheme="example"
  20. android:host="testhost"
  21. android:pathPrefix="/gizmos" />
  22. </intent-filter>
  23. </activity>

3.Check <data> in the <intent-filter> element, where the scheme value and host value are the values of the scheme field and host field as defined in the deep link.

4.<path> and <data> support three attributes, namely, path, pathPattern, and pathPrefix. They are defined as follows:

path: It specifies a complete path, which will be processed by the app only when it is identical to the configured path.

pathPattern: It specifies the regular expression of a complete path. This means, the received path will be processed by the app only when it complies with the regular expression specified by pathPattern.

pathPrefix: It specifies the initial part of a path. The received path will be processed by the app as long as its prefix is the pathPrefdix value.

query indicates the parameters that are transferred to the page. It is a key-value pair. Different parameters are connected with an “&” symbol.

Example: name=zhangsan&age=26

A deep link that is obtained according to the preceding example is: example://testhost/gizmospath? Name=zhangsan&age=26.

For details, the File Structure of an RPK will be provided later.