簡體   English   中英

單擊網絡鏈接應用程序將打開

[英]Clicking on the web link app will open

我正在嘗試構建一個應用程序,如果我單擊該鏈接,我的應用程序(如果已安裝)將打開。但是它不起作用,不知道為什么。它總是重定向到google.com

我的清單文件

<activity   android:name=".DeeplinkingActivity"
            android:label="@string/app_name"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@android:style/Theme.Holo.NoActionBar">
            <intent-filter android:label="@string/app_name">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <!-- Accepts URIs that begin with "http://example.com/soham" -->
                <data android:scheme="http"
                    android:host="example.com"
                    android:pathPrefix="/soham" />
                <data android:scheme="http"
                    android:host="www.example.com"
                    android:pathPrefix="/soham" />
            </intent-filter>
        </activity> 

我的test.html

<a href="intent://scan/#Intent;scheme=http;package=soham.com.deeplinking;S.browser_fallback_url=http%3A%2F%2Fgoogle.com;end"></a>

我認為問題出在html文件中。有幫助嗎?

您的鏈接不正確,您使用的是帶有ChromeAndroid Intents示例的主機。 您需要使用AndroidManifest.xml配置的hostpathPrefix

您的hostexample.com ,您的pathPrefix/soham ,鏈接將變為:

<a href="intent://example.com/soham#Intent;scheme=http;package=soham.com.deeplinking;S.browser_fallback_url=http%3A%2F%2Fgoogle.com;end">Deeplink</a>

試試這個:這適用於我的應用程序:

注意:在啟動器活動代碼中編寫以下代碼

<intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter android:label="@string/app_name" >
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <!-- Accepts URIs that begin with "example://WRITE YOUR HOST NAME” -->
            <data
                android:host="index.html"
                android:scheme="WRITE YOUR HOST NAME" />
        </intent-filter>
        <intent-filter android:label="@string/app_name" >
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <!-- Accepts URIs that begin with "http://example.com/WRITE YOUR HOST NAME” -->
            <data
                android:host="WRITE YOUR HOST NAME.com"
                android:pathPrefix="/index.html"
                android:scheme="http" />
        </intent-filter>
        <intent-filter android:label="@string/app_name" >
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="WRITE YOUR HOST NAME" />
        </intent-filter>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM