是否可以在许多其他应用程序使用的模块中使用深度链接? [英] Is It possible to use deeplink in a Module that is used by many other applications?

查看:72
本文介绍了是否可以在许多其他应用程序使用的模块中使用深度链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个供其他应用程序使用的.aar文件.在此模块中,由于付款,用户需要退出应用程序.付款后,我想打开该应用程序,然后单击网站上的一个按钮.如果在我的应用程序中,则可以通过添加 intent-filter 进行清单中的深层链接来轻松处理它.但是现在我不知道如何读取清单和读取应用程序上定义的深层链接.

我搜索了它,但找不到任何答案.

谢谢.

解决方案

您可以在Android模块(库)中添加 Activity ,并定义相同的 intent-filter 在您的 Activity 清单中.

因此,当浏览器完成付款流程后,他们可以使用深层链接触发您图书馆的 Activity .

我强烈建议您同时阅读 Android应用链接.>

通过这种方式,您可以处理 .aar 中的所有内容,最终应用程序开发人员不必为您扮演中继角色.

此方法有一个重要的收获,那就是当多个应用程序将您的 .aar 集成到同一设备上时要当心.在这种情况下,付款流程结束后,Android会向用户建议两个应用程序,这是错误的,并可能导致意外结果.

使用针对活动定义的意图过滤器中的 $ applicationId 键对此有一个简单的解决方法.只需确保完成后,浏览器就会使用正确的 applicationId 调用正确的回调URL.

以下是该活动清单的完整示例:

 <活动android:name =".. CallBackActivity"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 =" https"/>< data android:host =" www.yourDomainName.com"/>< data android:pathPattern ="payment/$ applicationId"/></intent-filter></activity> 

I'm trying to create an .aar file to be used by other applications. In this module, the user needs to go out of the application due to the payment. I want to open the application after the payment is finished and a button on the website is clicked. If it was in my application, I could easily handle it by adding an intent-filter for deep linking in manifest. But now I don't know how I can read manifest and read the deep link defined on the application.

I searched for it and I couldn't find any answer.

Thanks in advance.

解决方案

You can add an Activity to your Android module (library) and define the same intent-filter in the manifest for your Activity.

So when the browser is done with payment flow they can fire up your library's Activity Using Deep-Links.

I highly suggest to read up on Android App Links as well.

This way you can handle everything right in your .aar and end App developers don't have to play the relay role for you.

There is one important catch with this approach and that is to be careful when multiple applications have integrated your .aar on the same device. In that case after the payment flow, Android will suggest to the user both of the apps, which is wrong and might lead to an unexpected result.

There is a simple fix to this by using $applicationId key in the intent-filter defined for your Activity. Just make sure your browser will call the correct callback-URL with the correct applicationId when it's done.

Here is a complete sample of that Activity manifest:

<activity
            android:name=".CallBackActivity"
            android:label="@string/app_name">

            <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="https" />
                 <data android:host="www.yourDomainName.com" />
                 <data android:pathPattern="payment/$applicationId" />
            </intent-filter>
</activity>

这篇关于是否可以在许多其他应用程序使用的模块中使用深度链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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