问题
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.
回答1:
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>
来源:https://stackoverflow.com/questions/65407930/is-it-possible-to-use-deeplink-in-a-module-that-is-used-by-many-other-applicatio