简体   繁体   English

Android动态加载资源

[英]Android dynamically load resources

I am trying to use the DexClassLoader to download a JAR/APK in my app. 我正在尝试使用DexClassLoader在我的应用程序中下载JAR / APK。 I would like to modularize my app so I can download UI flows the user might go on demand instead of shipping them all together into my main app. 我想模块化我的应用程序,以便我可以下载用户可能需要的UI流程,而不是将它们全部一起发送到我的主应用程序中。

Loading the actual classes works fine and I managed to load some UI components which I can add to my host activity. 加载实际的类工作正常,我设法加载一些我可以添加到我的主机活动的UI组件。

My problem is that obviously I cannot access or add resources (Strings, drawables, layouts) to my downloaded package because they do not come with my host APK. 我的问题是,显然我无法访问或添加资源(字符串,drawables,布局)到我下载的包,因为它们没有我的主机APK。 Is it possible to dynamically load resources for my downloadable JAR/APK? 是否有可能为我的可下载JAR / APK动态加载资源?

You can "dynamically" download any resources you want, put them in a directory you choose, and use them in your app. 您可以“动态”下载所需的任何资源,将它们放在您选择的目录中,并在您的应用中使用它们。 It's what I currently do in an app. 这就是我目前在应用程序中所做的事情。 I don't think you can put them in the same directory with the resources that are in your project, but does that matter? 我认为您不能将它们与项目中的资源放在同一目录中,但这有关系吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM