Android Development Best Practices

Android Development Best Practices


Let's take a glance at a number of the most effective practices within the style and development of automation applications.
For starters, after you develop associate automaton application, you ought to prepare it to run on a range of devices and things.
Every automaton device could be a family. once a friend goes on the road, it means different members of the family area unit seemingly to be infected too.
Did you recognize that once one app asks for memory, if there's no free memory, automaton responds by closing down different applications therefore it will give that memory? Then if the user switches to it application, it'll ought to be restarted.
When one application consumes a lot of memory, uses a lot of processor and GPU or consumes a lot of battery, each different application suffers. And it's the potential to ruin the complete device's user expertise.

Performance matters.
If you would like to grasp a lot of regarding automaton performance, start here.
And here.
Here area unit some extra best practices to follow once making automaton apps:
Use the counseled automaton design.
Learn about the automaton application design from here and below.

Always maintain the standard of the code. plenty of quality. this can be not on the subject of most valuable player / MVVM / MVC / etc, however conjointly regarding each piece of code in each a part of your application.

Memory leak detection and fixing on the automaton. browse this text to grasp.

Always embrace unit tests. this can be the foremost vital a part of application development. I like to recommend running the unit check on the JVM because it is far quicker than running it on associate automaton device or mortal. If you wish any automaton dependencies, use Roboletrick. If you wish to mock one thing whereas testing, use Makito.

Use dependency injectors to facilitate testing. learn the way to use Dependency convenience here and here.
Always embrace practical UI tests. practical checks test the performance of your app from a user's perspective. They launch your app and check its effectiveness. If your app doesn't move with different applications, here you'll use automaton instrumentation, because it solely runs together with your app. If there's any interaction with different applications, use UIAoutmator to check this practicality.

As I aforesaid before, continuously write code for higher performance.

Beware of the low price. a little leak can sink a good ship. - writer

Use Progard in your unleash version. this may take away all of your unused code, which can cut back the APK size.

Use debugging tools. I recommend victimization the automaton rectify the information. This library is your relief. automaton rectify information could be a powerful library for debugging databases and sharing preferences in automaton applications. it is a terribly handy tool for viewing databases and sharing preferences right in your browser.

Use string.xml. Adding text as a string resource is often effective within the long-standing time, particularly once adding support for a replacement language.

Create separate layouts for UI elements which will be reused. Then use the tag enclosed within the XML. Another straightforward tag is the  tag. It acts as a pseudo parent associated helps to urge obviate a discretional root viewgroup. examine it here.

Place the launcher icon within the mipmap-folder. whereas making separate APPs for various densities, drawable folders for different densities area unit stripped away. this may obscure the icons on devices that use high-density launcher icons. Since mipmap folders aren't cut, it's continuously best to use them to incorporate launch icons.


Use the scale and selector rather than the image the maximum amount as potential. This additional reduces the scale of the APK.

Avoid deeper layers within the layout. A deep layering of the scene slows down your UI, no ought to mention that your layouts area unit is tougher to manage. Deep depictions area unit largely avoided victimization the right viewgroup. Use a restricted layout.

Depending on your use case, use a quick protocol library like automaton Networking, Volley or Retrofit.

When passing knowledge to intents or bundles, use the Persistable category rather than the serializable. publication of associate object that implements a reliable interface is far quicker than victimization Java default publication. a category that implements the Serializable interface has been known as serializable and Java serializes it victimization reflection (which makes it slower). once victimization the Parsable interface, the complete object isn't mechanically serialized. Rather, you're th See more

No comments

Theme images by fpm. Powered by Blogger.