12

我一直在尝试通过电子邮件上的链接或某些社交网站上的帖子来启动应用程序。问题是在某些设备或 android 上的某些 gmail 应用程序中不显示我指定的锚标签或链接。

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:scheme="myappname" />

我正在发送带有这个锚标签的电子邮件

myappname://processtobedone/?id=1

它适用于我在华为设备上的电子邮件应用程序,但在设备的默认 gmail 应用程序中,它没有显示它有一个链接,并且在某些设备中,它默认附加 https: 作为标签的后缀并启动浏览器。

4

4 回答 4

20

<intent-filter>您可以使用一个标识您控制的 URL的而不是使用自定义方案:

<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.this-so-does-not-exist.com"
        android:path="/something"
        android:scheme="http"/>
</intent-filter>

然后,链接http://www.this-so-does-not-exist.com/something将在安装了您的应用程序的设备上显示您的应用程序(在选择器中以及 Web 浏览器中),并在没有您的应用程序的设备上显示您的网页。

于 2013-02-19T15:04:17.807 回答
2

创建一个真正的链接 (http:) 进入您控制的网站,例如 amazon s3 上的静态网站,使用该网站上的 javascript 检测 android 用户代理,然后重定向到带有锚标记的链接。

于 2013-02-19T14:48:53.770 回答
0
<activity
android:name=".SplashEmailActivity"
android:screenOrientation="portrait"
android:exported="true"
android:launchMode="singleInstance" android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:windowSoftInputMode="stateHidden|adjustResize" >

<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:scheme="http"  android:host="your.domain.name"/>

</intent-filter>

</activity>
于 2016-05-18T11:33:40.707 回答
0

要在设备上触发应用程序链接,例如,您的案例myappname://processtobedone/?id=1,最简单的方法是创建一个基本的 html 页面文件(名称为deeplink_test.html)并发送到您的电子邮件,然后打开此电子邮件并单击 html 文件,打开Chrome 浏览器并单击锚链接。

<html>
    <head>
        <title>DeepLink Test</title>
    <head>
    <body>
        <a href="myappname://processtobedone/?id=1">run deeplink</a>
    <body/>
</html>

于 2019-02-06T13:13:37.767 回答