浏览器深度链接无法运行Android

时间:2015-11-10 04:00:18

标签: android deep-linking

Deep Linking无法在android中运行。我在这里贴了我的清单代码。当我测试时,它进入网站,而不是在我的应用程序中打开我的活动。有人可以帮我解决这个问题吗?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.clinicloud.app" >

    <application
        android:name=".MainApp"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar" >
            <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="www.XXXX.com"
                    android:pathPrefix="/xyz"
                    android:scheme="http"/>
            </intent-filter>
        </activity>
        <activity
            android:name=".OnboardingActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ProfileViewActivity"
            android:label="@string/title_activity_profile_view"
            android:theme="@style/AppTheme.NoActionBar" >
        </activity>
    </application>

</manifest>

更新:

adb shell am start -W -a android.intent.action.VIEW -d“http://www.clinicloud.com/xyz”com.clinicloud.app

使用adb进行测试会打开应用,但只是浏览器无法打开应用。

2 个答案:

答案 0 :(得分:1)

Manifest.xml

中添加此代码
<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="www.clinicloud.com"
        android:path="/xyz"
        android:scheme="http" />
</intent-filter>

为测试创建另一个项目并在代码

下运行
Intent i = new Intent(
    Intent.ACTION_VIEW , Uri.parse("http://www.clinicloud.com/xyz")
);
startActivity(i);

您也可以在链接中传递参数。有关详细信息,请参阅我的博文Make a link in the Android browser start up my app?

答案 1 :(得分:0)

按照 Android 开发人员团队的建议,通过 adb 测试深层链接非常烦人。我们不会明白我认为的问题的要旨。 我们想要一种直接的方法,例如将链接粘贴到已安装该应用程序的同一设备中的浏览器,点击 GO,然后该应用程序出现。但不幸的是,它不起作用。

原因:

这不是一个纯粹的链接,当你去浏览器的 URL 搜索时,它实际上是一个不同的 URL,例如:'https://www.google.com/search?....'

解决方案:打开纯链接

  1. 正如@Parag Chauhan 建议的那样,使用另一个应用程序打开链接,确定它是一个绝对有效的解决方案,因为它是一个纯链接。然而,这并不像预期的那样实用。

  2. 或者,

    2.1.您可以使用链接构建自己的简单网页(简单文件*.html),然后单击它打开一个纯链接。以下是网页示例:

<html>
    <h1>
        <a id="deeplink" href="ss.wohui.learn://subscribed">Deep Link</a>
    </h1>
</html>

2.2.将 ss.wohui.learn://subscribed 替换为您的深层链接。

2.3.将文件下载到您的设备。

2.4.用浏览器打开。

2.5。点击深层链接。

2.6.应用程序将启动。

相关问题