Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Expansion apk

I was going through the docs of APK EXPANSION FILES in android and I was wondering that can we have all layout files in the patch apk and application's business logic in main apk ?

I read this Android Apps Break the 50MB Barrier too.

I tried creating this but the problem I faced was our widget names need to be in R.java file which is generated automatically..If I have layout files in patch file not in the main file then I am unable to refer then using R.id.xxx.

So Please tell me if this is possible or not ?

If this is possible then how it can be achieved ?

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

like image 586
Shruti Avatar asked May 02 '13 06:05

Shruti


1 Answers

Speaking straight, It's not possible to separate the layout files from apk and then trying to access it using R.id.whatever

Expansion files are meant to store the assets such as media, docs, and other such static things which your application uses and the content of the expansion pack is stored on device's shared storage and is not linked with the apk file. To access the assets of the expansion file, you must code your application to read them from that device's shared storage location.

Coming back to the question of storing the layout files in an expansion file. To achieve this, you will have to write your own layout parser with the basic functionality similar to LayoutInflator. You can not use LayoutInflator to parse any layout file which is not part of the apk or stored on any external storage. So the idea is to store your layout files in the expansion file (which will be out of apk, on device shared storage), parse the file using your own parser, and add the views to the main layout at runtime. Though you wont be able to access your views using R.id.whatever but you can always use visual tree to access the views or while parsing the views store the referenced objects to access them for later use.

Hope this gives you a starting point.

like image 129
Vinod Maurya Avatar answered Oct 04 '22 16:10

Vinod Maurya