本文介绍了具有动态功能的即时应用程序始终显示带有1个选项的消歧对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在尝试动态功能和Instant Apps。 要在各种功能之间导航,请使用深层链接。I'm experimenting with Dynamic Features and Instant Apps.To navigate between various features, I use Deep Links.每次导航到另一个活动时,都会看到消歧对话框少于1秒,其中包含列出了1个应用。请注意, Once和 Always(在荷兰语中)的选项是如何变灰的。Each time I navigate to another Activity, I see the disambiguation dialog for less than 1 second, with 1 app listed. Notice how the options for "Once" and "Always" (in dutch) are greyed out. 示例Github项目我创建了最小样本,它与我在Github上的当前结构相匹配。需要Android Studio 3.5-RC2I created a minimalistic sample, that matches my current structure on Github. Requires Android Studio 3.5 - RC2 某些上下文:我非常有信心,深层链接配置正确。但是既然你们还是想检查一下,这里是配置:I'm quite confident, the deeplinks are configured correct. But since you guys want to check that anyway, here's the configuration: 1-清单:<activity android:name=".ProfileActivity"> <intent-filter android:autoVerify="true" android:priority="100"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="giddy.entreco.nl" android:pathPrefix="/profile" android:scheme="http" /> <data android:scheme="https" /> </intent-filter> </activity> 2-资产链接 我的域包含可公开访问的 assetlinks.json 3-Sha是正确的 我使用的sha是正确的3 - Sha's are correctThe sha's I use are correctExecuting tasks: [signingReport] in projectSHA1: 3A:52:19:77:C1:AD:18:F4:98:21:77:74:37:DC:9B:89:02:64:6E:C6SHA-256: 25:DD:C3:7B:8E:35:D3:39:D5:D4:6C:B5:EA:7D:14:AF:82:EC:9C:56:A6:F5:76:A3:E1:D7:69:B3:EC:58:72:E8Valid until: Saturday, March 21, 2048 4-确认的数字资产链接文件 所有支票均通过 https:// digitalassetlinks .googleapis.com / v1 / statements:list?source.web.site = http s://giddy.entreco.nl& relation = delegate_permission / common.handle_all_urls 5-测试URL意图 也可以!唯一的问题是我在短暂的时间内看到了消歧对话框。5 - Testing a URL intentAlso works! The only problem is I see the disambiguation dialog for a brief period. 其他信息 我在所有模块中都使用了 apply插件:'com.android.dynamic-feature'( app 当然) Android Studio:3.5 RC2; Android-gradle-plugin:3.5.0-rc02Android Studio: 3.5 RC2; Android-gradle-plugin: 3.5.0-rc02我的设备是OnePlus6-带有氧气9.0.7& Android 9My Device is a OnePlus6 - with Oxygen 9.0.7 & Android 9 google官方样本还显示我的设备上的这种行为某些Samsung设备的行为不同。它没有显示使用1消除歧义选项,而是列出了我的应用两次,并且会一直等到您选择一次或始终。 (请注意,我是从Play商店的发布前报告中获得的)Some Samsung devices, behave different. Instead of showing the Disambiguation with 1 option, it lists my app twice, and will keep waiting until you either select Once or 'Always'. (Note, I got this from the pre-launch reports in the play store)无论我构建APK,应用程序捆绑包还是通过Google Play下载,我都会看到这种行为。总是一样。I see this behaviour, no matter if I build an APK, an App Bundle or download through Google Play. It's always the same.有什么建议可以消除烦人的对话框吗? 当我分析apk /捆绑包时,我确实看到了两个特定于 Activity 的条目。不仅在基本模块的清单中,而且在配置文件模块的清单中。我对Android / PlayStore在安装模块时如何合并这些清单几乎一无所知,但我想在这种情况下查看对话框可能很有意义。Any suggestions to get that annoying dialog out of the way?When I analyse the apk/bundle, I do see two entries for the specific Activity. Once in the base module's manifest, but also in the profile module's manifest. I have little understanding of how Android/PlayStore merges those manifests while installing modules, but I guess it could make sense to see the dialog in this case.推荐答案所以是的...我相信我以前已经看到过,从一种动态功能导航时,这是一种奇怪的行为。通过URL意向(即时)到另一个(非即时)。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.在解决此问题之前,我不建议您使用URL意向在模块之间导航,使用反射直接进入另一个模块的活动,例如: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)}其中 doesModuleExist()检查是否有以下情况:Where doesModuleExist() checks if either: 正在检查示例清单,看来您的个人资料模块不属于您的示例模块即时应用程序 dist:instant = false ,因此您将永远无法访问它e您可以简单地执行 isNotInstantApp()来检查,并且永远不会在作为即时应用程序时尝试启动。examining your sample manifest, it looks like your profile module is not part of your instant app dist:instant="false", so you would never have access to it, therefore you could simply do a isNotInstantApp() check instead and never attempt the launch while as instant app.一旦在已安装的应用程序中运行,则从技术上讲您无需检查,因为它始终是 include = trueonce in your installed app, then you technically don't need to check, as it is always include="true",但是如果您的配置文件模块是onDemand模块,或者只是出于安全预防措施,则应使用 splitInstallManager.getInstalledModules(),请参见 / app-bundle / playcore#manage_installed_modules (注意,您也可以在您的即时应用中使用此API)but if your profile module is an onDemand module, or just for safety precautions, you should utilize splitInstallManager.getInstalledModules(), see /app-bundle/playcore#manage_installed_modules (note, you can also use this API in your instant app)设备,这可能意味着它们在拦截和处理该URL意图方面实现了细微的差异,并且/或者它只是一个不同的Android版本(pre-O与O +)。And since it looks like this odd behavior varies between different devices, that might mean they've implemented subtle differences in intercepting and handling that URL intent, and/or it's just a different Android version (pre-O vs O+).也是,关联多个软件包名称到 common.handle_all_urls 的单个网站域时,当系统尝试在您的应用上线时尝试验证关联时,可能会导致其他一些不当行为。Also yes, associating multiple package names to a single website domain for common.handle_all_urls might cause some additional misbehavior when the system tries to verify the association when your app goes live. 这篇关于具有动态功能的即时应用程序始终显示带有1个选项的消歧对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-02 23:58