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.

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.


Need Your Help

Android: Change Button background in ListView Row with onClick

android listview button onclick adapter

My rows contain a button that has its own click listener set in my adapter's getView. I'm able to distinguish between my button clicks and the actual row item clicks using

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.