如何通过链接打开应用程序而不要求用户在浏览器或应用程序之间做出选择,只需立即打开我的应用程序 [英] How to open app from a link without asking user to decide between browser or app, just open my app immediately

查看:306
本文介绍了如何通过链接打开应用程序而不要求用户在浏览器或应用程序之间做出选择,只需立即打开我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个intent-filter,我希望每次用户单击eeexample.com的链接以打开我的应用程序时

I have this intent-filter that I want that every time user clicks a link to eeexample.com to open my app:

<intent-filter>
    <data android:scheme="http" />
    <data android:scheme="http" android:host="eeexample.com"/>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

例如,当用户在gmail应用程序上单击eeexample.com时:

When user clicks eeexample.com on gmail app for example:

然后打开一个对话框,询问用户是否要像这样从我的应用浏览器打开此链接:

Which then opens a dialog which asks user if they want this link to be opened from my app or browser like this:

但是我只希望当用户单击链接时,它会打开我的应用程序,而不会询问任何问题.或者在最坏的情况下,只要求使用我的Appetit(而不是浏览器)打开它.这可能吗?

But I just want that when user clicks the link it opens ONLY my app without asking anything. Or in a worst case scenario to just ask to open it with my app which is Appetit not with browser. Is this possible?

所以看来这可能与应用链接有关,但是仅适用于API级别23(Android 6.0),但是我需要使用api级别15(Android 4.0),有什么想法吗?

So it seems this is possible to do with App Links but only for API level 23 (Android 6.0), but I need this for api level 15 (Android 4.0), any ideas?

推荐答案

只有使用适用于 处理应用链接的培训:

Android 6.0(API级别23)及更高版本允许应用程序将自身指定为给定类型的链接的默认处理程序.如果用户不希望该应用程序成为默认处理程序,则可以从设置中覆盖此行为.

自动处理链接需要应用程序开发人员和网站所有者的合作.开发人员必须配置其应用程序以声明与一个或多个网站的关联,并请求系统验证这些关联.反过来,网站所有者必须通过发布数字资产链接文件来提供该验证.

Automatic handling of links requires the cooperation of app developers and website owners. A developer must configure their app to declare associations with one or more websites, and to request that the system verify those associations. A website owner must, in turn, provide that verification by publishing a Digital Asset Links file.

这涉及创建适当的意图处理器,通过添加android:autoVerify="true":

This involves creating the appropriate intent handler and enabling automatic verification by adding android:autoVerify="true":

<activity ...>

  <intent-filter android:autoVerify="true">
    <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="www.android.com" />
    <data android:scheme="https" android:host="www.android.com" />
  </intent-filter>

</activity>

然后,必须通过声明在网站上进行更新网站关联,以确保网站所有者和应用开发者都协调一致,以允许该应用自动成为URL方案的默认设置.

Then, updates must be made on the website side by declaring a website association, which ensures that the website owner and the app developer both coordinate to allow the app to autoomatically become the default for a URL scheme.

这篇关于如何通过链接打开应用程序而不要求用户在浏览器或应用程序之间做出选择,只需立即打开我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆