Context download from APK file in Android

I am creating a component application for Android. In short, I would like to download the APK file at runtime and execute the code from it.

I have successfully used DexClassLoader to load and instantiate some classes, the problem is reading the APK resources.

I would like to create a custom Context object that I could use to load these resources (for example, with an instance of LayoutInflater ), similar to createPackageContext() , which does not work for my application, since it is only looking at installed packages.

+7
source share
1 answer
  InputStream in = getResources() .openRawResource(R.raw.fileName); 

and then just read this thread. This example will open the file res / raw / fileName.html for reading. However, I do not understand why it is so difficult to load classes to execute from your own apk file. If I misunderstood, and you need to download apk from some other file, then - who does not allow to open this file for input and reading from it? This is just a compressed ZIP archive. I think you could build your implementation by overriding data access methods, and your instance may contain a link to a file from where to read the data.

+1
source

All Articles