OpenSource For You

Things to be kept in mind while developing an Android app

-

Resolution-neutral UI: The applicatio­n must take advantage of Android’s modular structure to specify layouts and resources specific to the target form factors and DPI range. Additional­ly, all the relative layout calculatio­ns should be done with respect to the screen width and height (fetched from the official source giving device informatio­n) and dimensions. xml should be leveraged for specifying the same.

Separation of controller and business logic: As we know, the Activity derived classes defined in the app, control the various views of the app. And the activity life cycle is not under the control of the app itself. Hence, the complete business logic including all data structures must reside in a separate class other than Activity, so that the business logic data structures do not get re-initialise­d when the activity gets re-created.

Low memory handling: The app must seamlessly handle this condition and release the memory savvy resources at the earliest, prepare to save the state of the app and exit, if required.

Low battery handling: The app must seamlessly handle this condition and release the battery savvy resources at the earliest, prepare to save the state of the app and exit if required.

Caching: Input/output operations incur significan­t costs in mobile apps in terms of battery usage, memory, data network bandwidth and latency time. Hence, it would be wise to cache the data structures frequently required by the app.

Multi-threading: While complex apps do need to spawn multiple threads for background processing, achieving this in Android by way of services is pretty straightfo­rward and is the preferred way.

Broadcasti­ng intents: While broadcasti­ng intents, it is advisable to direct the broadcast for the specific target class only. Otherwise, the IPC will be sensitive to any other hacker app installed on the device.

Background operations: I/O, databases, networks and other time consuming operations must be done as part of AsyncTask or a separate service. Also, the applicatio­n must show some progress indication while any operation is in progress for over a few seconds.

Inter-process communicat­ion (IPC): When large data structure transfers are required through IPC, use Android Interface Definition Language (AIDL) instead of intent-based IPC. Android has superior IPC support in AIDL to deal with such cases efficientl­y.

Newspapers in English

Newspapers from India