开发者

Context load from an APK file in Android

I am building a component-based application for Android. In short, I would like to load an APK file during runtime and execute code from it.

I used DexClassLoader with success to load and instantiate some classes, the problem lies in reading the APK's resources.

I would like to create a custom Context object that I could use to load these resources (with a LayoutInflater instance for example), similarly to the createPackageContext(), which does not work for my applicati开发者_高级运维on since it is only looking into the installed packages.


            InputStream in = getResources()
                .openRawResource(R.raw.fileName);

then just read from this stream. This example would open res/raw/fileName.html for reading. I however do not understand why to load classes for execution from your own apk file in such a problematic way. If I misunderstand and you need to load from some other apk file, then - who prevents from opening that file for the input and reading from it? It is just a compresses ZIP archive. I think you could construct your implementation overriding the data access methods and your instance could contain the reference to the file from where to read the data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜