Android app link not working properly

I played with application links with a test case, but it does not work in my case.

I created two html files source.html and some_html_file.html in the resource directory. I upload the source.html file to the webview and and I go to some_html_file.html using this button. Look at the source that you will find out what I'm doing here.

source.html

<html>
   <form name = "type_1" action="some_html_file.html">
        <input type="submit" value="Example 1 - open some html file"/>
   </form>
   <form name = "type_2" action="example2://node/news/23">
       <input type="submit" value="Example 2 - go to news 23"/>
   </form>
</html>

some_html_file.html

<html>
<head>
    <meta property="al:android:url" content="example://node/news/23" />
    <meta property="al:android:package" content="com.example.uritest" />
    <meta property="al:android:app_name" content="UriTest" />
</head>
    <h3>This is uri test page.</h3>
</html>

Problem

Thus, by pressing the first button, I expect android os to read the tags of the <meta>target html file and show my activity, which has logic for processing intent.

AndroidManifest.xml

       <activity android:name=".HandleUriActivity">

            <intent-filter>
                <data
                    android:scheme="example"
                    />

                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <data
                    android:scheme="example2"
                    />

                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

Any help would be greatly appreciated.

From the logarithm, I see that -

D/WebViewCallback: shouldOverrideUrlLoading = file:///android_asset/some_html_file.html?     W/WebViewCallback: :///android_asset/some_html_file.html?

:

. . _2 source.html. 2 - 23 , HandleUriActivity.

host = node
authority = node
path = /news/23

, i.e. android os , (some_html_file.html), .

# 2:

@Eric B. , .

- .

<head>
    <meta property="al:android:url" content="example://node/news/23" />
    <meta property="al:android:package" content="com.example.uritest" />
    <meta property="al:android:app_name" content="UriTest" />
</head>

Google Chrome, Chrome . -.

+4
1

Deep Linking , . (WebView) , Deep Linking, , :

webView.setWebViewClient(new WebViewClient() { 
            public boolean shouldOverrideUrlLoading(WebView view, String url){
                if(url.equals(YOUR_URL))
                {
                   // Open Activity here
                }
                webView.loadUrl(url); 
                return false; 
            } 
        });

Deep Linking.

UPDATE

:

   <activity android:name=".HandleUriActivity">

        <intent-filter>
                    <data android:scheme="http"
          android:host="rahulchaurasia3592.imtqy.com" >

            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
+1

Source: https://habr.com/ru/post/1619798/


All Articles