Things to be kept in mind while de­vel­op­ing an An­droid app

OpenSource For You - - FOR U & ME -

Res­o­lu­tion-neu­tral UI: The ap­pli­ca­tion must take ad­van­tage of An­droid’s mod­u­lar struc­ture to spec­ify lay­outs and re­sources spe­cific to the tar­get form fac­tors and DPI range. Ad­di­tion­ally, all the rel­a­tive lay­out cal­cu­la­tions should be done with re­spect to the screen width and height (fetched from the of­fi­cial source giv­ing de­vice in­for­ma­tion) and di­men­sions. xml should be lever­aged for spec­i­fy­ing the same.

Sep­a­ra­tion of con­troller and busi­ness logic: As we know, the Ac­tiv­ity de­rived classes de­fined in the app, con­trol the var­i­ous views of the app. And the ac­tiv­ity life cy­cle is not un­der the con­trol of the app it­self. Hence, the com­plete busi­ness logic in­clud­ing all data struc­tures must re­side in a sep­a­rate class other than Ac­tiv­ity, so that the busi­ness logic data struc­tures do not get re-ini­tialised when the ac­tiv­ity gets re-cre­ated.

Low mem­ory han­dling: The app must seam­lessly han­dle this con­di­tion and re­lease the mem­ory savvy re­sources at the ear­li­est, pre­pare to save the state of the app and exit, if re­quired.

Low bat­tery han­dling: The app must seam­lessly han­dle this con­di­tion and re­lease the bat­tery savvy re­sources at the ear­li­est, pre­pare to save the state of the app and exit if re­quired.

Caching: In­put/out­put op­er­a­tions in­cur sig­nif­i­cant costs in mo­bile apps in terms of bat­tery us­age, mem­ory, data net­work band­width and la­tency time. Hence, it would be wise to cache the data struc­tures fre­quently re­quired by the app.

Multi-thread­ing: While com­plex apps do need to spawn mul­ti­ple threads for back­ground pro­cess­ing, achiev­ing this in An­droid by way of ser­vices is pretty straight­for­ward and is the pre­ferred way.

Broad­cast­ing in­tents: While broad­cast­ing in­tents, it is ad­vis­able to di­rect the broad­cast for the spe­cific tar­get class only. Oth­er­wise, the IPC will be sen­si­tive to any other hacker app in­stalled on the de­vice.

Back­ground op­er­a­tions: I/O, data­bases, net­works and other time con­sum­ing op­er­a­tions must be done as part of AsyncTask or a sep­a­rate ser­vice. Also, the ap­pli­ca­tion must show some progress in­di­ca­tion while any op­er­a­tion is in progress for over a few sec­onds.

In­ter-process com­mu­ni­ca­tion (IPC): When large data struc­ture trans­fers are re­quired through IPC, use An­droid In­ter­face Def­i­ni­tion Lan­guage (AIDL) in­stead of in­tent-based IPC. An­droid has su­pe­rior IPC sup­port in AIDL to deal with such cases ef­fi­ciently.

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.