Android Expansion apk

I was looking at the EXPANSION FILES APK documents in android, and I was wondering if we can have all the layout files in the apk patch and the business logic of the application in the main apk?

I read this Android application. Break the 50 megabyte barrier .

I tried to create this, but the problem I ran into was that the names of our widgets should be in the R.java file, which is generated automatically. If I have layout files in the patch file not in the main file, then I cannot link then using R.id.xxx.

So tell me, is this possible or not?

If this is possible, then how can this be achieved?

I also want to know what are the resources or assets that can be added to apt patch.

+8
android android-layout apk
source share
1 answer

Speaking directly, it is not possible to separate layout files from apk and then try to access it using R.id.whatever

Extension files are intended for storing assets such as media, documents, and other similar static things that your application uses, and the contents of the extension package are stored on the shared device storage and are not associated with the apk file. In order to access the assets of the extension file, you must encode your application in order to read them from the shared storage repository.

Returning to the issue of saving layout files in an extension file. To do this, you will have to write your own parser layout with basic functions like LayoutInflator. You cannot use LayoutInflator to analyze any layout file that is not part of the apk or stored on any external storage. Therefore, the idea is to store the layout files in an extension file (which will be absent in apk, on the general device storage), analyze the file using its own analyzer, and add views to the main layout at runtime. Although you will not be able to access your views using R.id.whatever, you can always use the visual tree to access the views or, when analyzing the views, store the objects referenced to access them for later use.

Hope this gives you a starting point.

+3
source share

All Articles