[英]Access Resources In Dynamic Feature Module of App Bundle
My usage scenario is a bit complicated. 我的使用场景有点复杂。
In the dynamic form, I only have some views and resources. 在动态形式中,我只有一些视图和资源。 Those views should have access to those resources.
这些视图应该可以访问那些资源。 In my base module, I will use these views from the activity of a basic module.
在基本模块中,我将从基本模块的活动中使用这些视图。 Both my application and activity replace the attachBaseContext method.
我的应用程序和活动都替换了attachBaseContext方法。
But when I download and install the dynamic form, my views can not access resources using the task context. 但是,当我下载并安装动态表单时,我的视图无法使用任务上下文访问资源。 However, resources are accessible from applicationContext.
但是,可以从applicationContext访问资源。
I do not understand how SplitCompat works. 我不了解SplitCompat的工作原理。 So the classes and resources loaded by the dynamic module connect only to applicationContext?
那么动态模块加载的类和资源仅连接到applicationContext吗?
This problem is probably caused by an Android Studio bug. 此问题可能是由Android Studio错误引起的。 Clean the project and invalidate the cache, or build the project again.
清理项目并使缓存无效,或再次构建项目。
You can take a look at how Dynamic Features are implemented in this sample . 您可以看一下此示例中如何实现动态功能。
There's sample code on how to open some resources, located in a dynamic module, from the base module . 有关如何从基本模块中打开动态模块中的某些资源的示例代码。
Plus, the samples includes others dynamic modules with activities in implemented in Java/Kotlin and native. 另外,这些示例还包括其他动态模块,这些模块的活动以Java / Kotlin和本机实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.