Disambiguation dialog is shown when opening activity with URI
The project doesn't build in Android Studio version 3.4.1. So I downgraded the gradle version to 3.4.2 (com.android.tools.build:gradle:3.4.2).
Steps to repro
- Click REQUEST INSTALL SPLIT INSTALL VIA URL button
- An disambiguation dialog is shown with apps of the same package name.
Even tried running the project with Android Studio v3.5 with the project gradle version 'com.android.tools.build:gradle:3.5.0-rc02' the same issue exists.
Looking forward for help. Thanks
I have the same problem, and created a simple repository to mimic my setup. Off course, when trying out this project, make sure you update the domain and packagename of the app, to reflect your assetlinks.json file
https://github.com/Entreco/Dynamic-feature-disambiguation/tree/master
Found an open issue here in issue tracker. Our entire application depends on this URI intent navigation. This bug is complete show stopper on implementing dynamic feature.
@keyboardsurfer do you have any update on this fix? Any workaround do you suggest ?
Appreciate your help!
I asked the same question on StackOverflow.
Until the issue is fixed, the suggested work-around is to:
So yes... I believe I have seen this before, it is some odd behavior when navigating from one dynamic-feature (instant) to another (non-instant) via a URL intent.
Until this gets addressed, I don't recommend using a URL intent to navigate between modules, instead, use reflection to directly get to the other module's activity, example:
if (doesModuleExist()) { val intent = Intent() .setClassName(getPackageName(), "com.sample.ProfileActivity") .addCategory(Intent.CATEGORY_DEFAULT) .addCategory(Intent.CATEGORY_BROWSABLE) startActivity(intent) }
Which basically means, to use URL intents only for starting your instant app/dynamic features. But navigation between features in your app, should use reflection
@Entreco Thanks for your update!
we believe, using reflection is not a scalable solution. also it involves lot of code changes. Any quick workaround available on this ?
Agreed that reflection feels wrong/ awkward. But that's the only work around I have heard so far.
Would be nice to get an update about this issue from people working on the project
In order to launch an activity via URL without the disambiguation dialog you might have to call setPackage with your package name to handle the intent.
I see the disambiguation dialog in my sample project: https://github.com/Entreco/Dynamic-feature-disambiguation
Calling setPackage does not seem to make a difference (at least with my setup, device and buildtools ):
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://giddy.entreco.nl/viewer/"))
.setPackage(packageName)
.addCategory(Intent.CATEGORY_DEFAULT)
.addCategory(Intent.CATEGORY_BROWSABLE)
startActivity(intent)
Thanks @keyboardsurfer for the quick response.
As @Entreco mentioned; Calling setPackage doesn't fix this issue.
Hi, Anyway to fix this issue ? @keyboardsurfer
@NagendraHariKarthick I was facing the same issue, and found a possible solution: https://siebedatema.medium.com/dynamic-feature-navigation-with-deep-links-on-android-7d04b6fda10b
The important part is using this extention function:
fun Intent.convertToSafeDynamicFeatureModuleIntent(context: Context) {
//Get list of all intent handlers for this Intent. This should only be the actual activity we are looking for
val options = context.packageManager.queryIntentActivities(this, PackageManager.MATCH_DEFAULT_ONLY)
//Set the activity that supported the given intent
setClassName(packageName, options[0].activityInfo.name)
}