【问题标题】:Clicking on the web link app will open单击网络链接应用程序将打开
【发布时间】:2015-10-19 11:23:36
【问题描述】:

我正在尝试构建一个应用程序,如果我单击链接,我的应用程序(如果已安装)将打开。但它不起作用,不知道为什么。它总是重定向到 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 文件中。有什么帮助吗?

【问题讨论】:

    标签: java android uri deep-linking


    【解决方案1】:

    您的链接不正确,您使用的是Android Intents with Chrome example 的主机。您需要使用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>
    

    【讨论】:

    • 谢谢。它正在工作。你能告诉我如何通过链接发送参数。假设我必须发送 id =1,2。
    • 不客气。 This answer 详细解释了如何将参数作为附加参数传递给应用程序。
    【解决方案2】:

    试试这个:这适用于我的应用:

    注意:在您的启动器活动标签中写入以下代码

    <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>
    

    【讨论】:

    • 这是示例应用程序,不在 playstore 中,没有任何网站。那么 android:scheme 和 android:host 应该是什么
    猜你喜欢
    • 1970-01-01
    • 2019-06-16
    • 2017-08-07
    • 1970-01-01
    • 2014-12-09
    • 2017-09-27
    • 2013-03-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多