Android App Links不起作用,是因为Annotations吗?

时间:2017-01-19 18:17:17

标签: android android-6.0-marshmallow android-annotations applinks

我是Android新手,还在学习它,我有一个使用AndroidAnnotations的项目,并希望实现App Links。

我阅读了文档(here),甚至在Stackoverflow上阅读了一些问题。

在文档之后,Manifest中的intent-filter是:

<intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.category.DEFAULT" />
            <action android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="http" android:host="real.host.here" />
            <data android:scheme="https" android:host="real.host.here" />
</intent-filter>

意图是在一个活动中,唯一与我发现的所有例子不同的是我的活动是这样的:

<activity
    android:name=".activities.MainActivity_" ...>
    <intent-filter...>...</intent-filter>
</activity>

由于AndroidAnnotations,名称为“.MainActivity_”,而不是“MainActivity”。

除此之外,托管的assetlinks.json可通过HTTPS连接访问,这是我的文件:

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.my.package.name",
    "sha256_cert_fingerprints":["32:D9:9E:17:2E:C7:B4:82:12:96:C8:3E:D1:51:56:3F:7C:ED:97:69:F9:4A:39:54:4C:7B:AD:8A:AD:27:8F:45"]
  }
}]

SHA256指纹来自我用来构建应用发布版本的证书。

我已经使用 Statement List Generator and Tester工具进行了测试,结果很成功。

只是为了确定,我总是使用已签名的apk和手机进行测试我正在测试它是Android 6.0。

当我用此

确认数字资产链接文件时
https://digitalassetlinks.googleapis.com/v1/statements:list?
source.web.site=https://<domain1>:<port>&
relation=delegate_permission/common.handle_all_urls

我收到此消息:

... "debugString": "********************* ERRORS *********************\nNone!\ ...

但是当我尝试这个命令时

adb shell am start -a android.intent.action.VIEW \
-c android.intent.category.BROWSABLE \
-d "http://<domain1>:<port>"

它会打开浏览器,而不是应用程序。

我真的很想知道这里可能出现的问题。

1 个答案:

答案 0 :(得分:1)

我发现了自己的问题。

首先我发现在intent-filter中,

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

应该是

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

但即使在那之后,它也无法正常工作。所以我找到了真正的问题。

见这里:

<data android:scheme="http" android:host="real.host.here" />
<data android:scheme="https" android:host="real.host.here" />

问题是,我的主机只提供HTTPS协议,我的网站没有HTTP。删除“http”数据行后,它就像一个魅力。使用AndroidAnnotations没有问题。

相关问题