处理权限:将大型应用程序的一项活动转换为即时应用程序 [英] Handling Permissions: Making one activity of a large app into an instant app
问题描述
有人要求我在我正在开发的基本应用程序中从Play商店中打开一个即时应用程序模块.
I have been asked to make an instant app module openable from play store in a base app which I am working on.
基本应用程序很大,有很多活动.与即时应用程序所允许的权限相比,它还使用了更多权限.
The base app is large with lots of activities. It also uses many more permissions than those allowed for instant apps.
是否有可能仅通过一项仅使用允许的权限的活动来制作即时应用程序模块?
Is it possible that I make the instant app module from only one of the activities which utilizes only the allowed permissions?
如果是,我应该怎么做?
If yes, how should I go about it?
换句话说,即使基本应用程序使用了更多权限,我是否可以在即时应用程序模块的清单文件(instant/AndroidManifest.xml)中声明允许的权限?
In other words, can I declare the allowed permissions in the manifest file of the instant app module (instant/AndroidManifest.xml) even though the base app uses many more permissions?
我问这个问题是因为官方文档没有提及在Instant/AndroidManifest.xml中声明权限的方法
I am asking this question because the official documentation doesn't mention a way to declare permissions in instant/AndroidManifest.xml
推荐答案
换句话说,我可以在清单中声明允许的权限吗?即时应用程序模块的文件(instant/AndroidManifest.xml)甚至虽然基本应用程序使用了更多权限?
In other words, can I declare the allowed permissions in the manifest file of the instant app module (instant/AndroidManifest.xml) even though the base app uses many more permissions?
是的,您可以声明仅在com.android.feature模块中存在的权限.这样做与您的主清单没有什么不同,请参见
Yes, you can declare permissions that only exist in your com.android.feature modules. It is done no different than in your main manifest, see an example from googlesamples/android-instant-apps/analytics/feature/AndroidManifest.xml
注意:如果此功能也是通过应用程序模块的gradle中的 implementation project(':feature')
安装的应用程序的一部分,则其清单内容将被合并,权限,因此您无需重复这些权限.
note: if this feature is also a part of the installed-app via implementation project(':feature')
in the application module's gradle, then its manifest contents will be merged, permissions included, so you don't need to duplicate those permissions.
但是,由于您的即时应用程序和已安装应用程序之间的权限有所不同,因此您可能会遇到播放过滤器)在它们之间进行同步,以使已安装应用程序的可定位设备不会比即时应用程序窄.
But as your permissions diversify between your instant and installed apps, you may run into Google Play Console error - Non-upgradable to installed app errors that you'll have to watch out for. Just make sure that your permissions, uses-feature, and uses-implied-feature (ie Play filters) are synced between them so that the targetable devices for your installed app is not narrower than your instant app.
这篇关于处理权限:将大型应用程序的一项活动转换为即时应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!