I am working on application with multiple types choices and every type has different UI, content and operations.
If i packaged all activities, xml and drawables files inside same .apk file for all users with showing and hiding methodology it's an inefficient way as it waste user space and download time.
Are there another ways to upload activities,xml and drawables files to external servers and download them based on user selected choice?
appreciated any help.
thanks.
You may download the Activities and other Java classes from the server and load them up, perhaps even Drawables, but XML part would be a tricky one.
If you can manage to avoid XMLs by creating layouts with Java if Layout is what you meant by XML, the answer is yes, it is possible.
You will need to explore how to load Java classes at runtime.
the answer is here
Multiple APK Support
-----> The build system enables you to automatically build different APKs
that each contain only the code and resources needed for a specific
screen density or Application Binary Interface (ABI). For more
information see Build Multiple APKs.
Related
in our company we are creating a product that is sold to different customers only changing visuals aspects (logos, trademarks, text, etc ...). We doubt how to handle this as we need to maintain a base (with their testings) and customized versions of these products (different package name and some modifications asides).
The more difficult for us is we handle this with Git and projects libraries that need to keep together. We need to keep easy to create new products and maintain updates for each one quickly
which workflow do you recommended to handle this? we have a mix of git + submodules + branches + libraries projects, but it's hard to create an android libproyect base
I don't fully understand your question so if you could write some more info it would be useful for others to help you. The part I understood was the problem of managing multiple projects that have same code but different resources and manifest files. On our project we had a similar problem developing for 3 different servers where code would stay the same but links, api keys and package names would need to change, even logo images might need to be different sometimes adding "integration icon/development icon" etc. What I did in this case was to create one Android library project where all the code and resources that are shared are stored and in our case 3 other projects that reference the library and have special res/drawable folder and strings in value folder where api keys and other settings are stored. This turned out to be great fit for our purposes since you can just pick a run configuration for project to be run and Android will load required resources. You could do this for any number of projects without any files being duplicated and taking space in your git repository. This approach actually allows you to let your designers change drawables for diffident projects by putting different images in folders without or with just a little involvement from developers. If you are skill full you could even write some ant scripts that build and sign projects for them so they can test on devices to see how real app looks.
In the app I'm building, I'm using multiple languages. It's easy to add a different language into an app by adding a new folder (for example: values-fr) and adding a new strings.xml file in there. But I have pretty large text files (complete articles) that I need to add. These articles are also written in different languages. What is the best way to add them to my app?
I'd consider using res/raw-<qualifiers> as alternative to the assets. The raw folder can store arbitrary files in their - you guessed it - raw form. For example, a 'Hello World' article written in French and English, would be stored under:
res/raw-fr
res/raw-en
The raw resource can then be opened by calling openRawResource(int id) on a resources object, similar to how it works for other resources like drawables, strings etc. The id's generated by the framework will be in the familiar format of R.raw.filename (without file extension).
The benefit of using this approach is that you can fully leverage Android's localization system, meaning that as a developer you basically don't have to worry about any of that at all. You can also easily add more qualifiers to further filter on device characteristics (e.g. screen size, density, platform version etc etc - see here for a full overview). The downside is that it imposes some limitations in terms of the original file name/extension and doesn't support a proper folder/file hierarchy.
The 'better' approach (/raw vs /assets that is) will probably depend on your project's requirements.
I would probably use assets -- that is, create assets/data/fr/ and store the fr files there. Note that assets require explicit extraction -- which probably is good since you may save memory having only one set of articles installed.
Another possibility is to place everything on an http server, and thus make both keeping and accessing the articles somebody else's problem :) .
BTW, if you files are really big, you will have to install the application without them, and download the articles later. (There are restrictions on the apk size.)
I am trying to write a modular extensible application to deploy in Android. The idea is to provide an API to allow the creation of custom functionality for the app that may include custom layouts and other resources. This custom functionality will be loaded, at runtime, from another location (e.g. SD Card).
Currently I am able to load .jar files from this location and work with them as I like, unfortunately I can only include references to layouts and resources that are also present in the "Main" project.
I have been unable to find a good way to reference an entire library project, resources included. I essentially want each custom piece to contain all the resources it needs to display and run itself.
Right now I am toying with the idea of including an "Assets" project that can be referenced by each of the modules to be a central area to store layouts and other resources. Unfortunately this would require me to have a project that must be loaded by any other project that needs to be built.
Another idea was to include the layouts, images and strings, along with the jar files, in a folder and load those at run time. I don't think this will work well since the layouts seem to be pre-processed at compile time in some way and cannot be inflated at run time.
Does anyone know a way for me to include all the resources and code into a single, dynamically loadable, file that I can then access at runtime?
Does anyone know a way for me to include all the resources and code into a single, dynamically loadable, file that I can then access at runtime?
That is not supported. It is rather likely that it will never be supported, though it is possible that it might work with the new build system that is under development.
I am trying to use the DexClassLoader to download a JAR/APK in my app. I would like to modularize my app so I can download UI flows the user might go on demand instead of shipping them all together into my main app.
Loading the actual classes works fine and I managed to load some UI components which I can add to my host activity.
My problem is that obviously I cannot access or add resources (Strings, drawables, layouts) to my downloaded package because they do not come with my host APK. Is it possible to dynamically load resources for my downloadable JAR/APK?
You can "dynamically" download any resources you want, put them in a directory you choose, and use them in your app. It's what I currently do in an app. I don't think you can put them in the same directory with the resources that are in your project, but does that matter?
I have android application (single apk file) with code and ga lot of graphics, It takes a lot of space. I want to devide my huge application into two parts. The first is a source code and minor graphice (takes low space), the second part includes all other graphic. When user launches first application, it uses graphic from another application.
1) Is solution it possible?
2) If it is possible, how can I access from first apk to a resource file at SD card, whick stores in another zip/archive/jar/or apk?
Maybe you can provide your graphic as a Content Provider in one application and then read them in another application.
You can use Library Projects to achieve this.
There are a number of ways to do this. One of the more popular is to require the application to download the large graphics on "first-run". This is done by most large game apps.