Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin之间可以共享资源吗 #34

Closed
duanhaolxc opened this issue Jul 1, 2017 · 3 comments
Closed

plugin之间可以共享资源吗 #34

duanhaolxc opened this issue Jul 1, 2017 · 3 comments
Labels

Comments

@duanhaolxc
Copy link

You may also want to read our issue guide.

RePlugin version:

Android compile SDK version:

Android ROM:

@jiongxuan
Copy link
Contributor

@erhu 所说的是业内用得较多的“共享资源”方案,也即需要修改Aapt以及做addAssetPath,以保证“宿主和插件用同一套资源”的效果。

出于稳定性的考虑,我们采用的是“独立资源”方案,插件与应用间是完全独立的。但“独立”不代表“不能共用”。实际上,我们卫士有很多插件(如WebView等)都是需要将自己的资源(如Layout-XML等)共享给宿主和其它插件。这时候我们的做法是有两种:

  • 可以直接通过调用RePlugin.fetchResources接口,直接拿到资源
  • 通过反射获取View来间接拿到资源。

例如360手机助手所用的“换肤CommonView”就是采用第二种方式来做的,目前来看,没有问题。

@whosmyqueen
Copy link

whosmyqueen commented Jul 2, 2017

@jiongxuan 能实现通过R文件来调用资源的吗

@jiongxuan
Copy link
Contributor

可以通过反射的方式获取R来调用。我们有插件是这样做的。

但要采用“共享资源”方案,则因为考虑到Hook的影响(各种Resources的厂商判断,addAssetPath等),所以暂时没有采用此方案(或者说,2013年我们就采用了,但后来因为适配问题最终下线了)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants