Developers must know: top ten key points to improve Android Application Development Performance

Source: Internet
Author: User

 

As any mobile platform continues to develop and its applications are constantly improved, quality becomes crucial if development is successful. Today, users require that they decide to install Android applications on their own devices to respond quickly and with reasonable performance. If those applications fail to provide exciting features and stable user experience, they will soon be uninstalled. This article describes the top 10 key points for Android to improve development performance.

 

 

Although Android smartphones and tablets are faster than a day, developers must remember that their applications are still running in a resource-intensive environment, this environment relies primarily on batteries and processors that are unmatched by the latest desktop or laptop. Some of the methods described below can help your applications to "slim down" or "Ten Key Points for Android to improve development performance" so that they can run smoothly on Android devices today and tomorrow.

 

 

 

Let's talk about several programming points to ensure that the application responds quickly.

 

First, you must have good programming habits.

 

To become a good resource administrator, you must use both common sense and recognized algorithms and standard design patterns. In terms of resource usage, if you open the resource, remember to close the resource. Try to get it as late as possible and release it as early as possible. These long-standing programming principles also apply to your Android applications, especially if they use underlying device services.

 

For example, assume that an application you write depends on a location-based service. Do not start registration or obtain the latest location information unless you absolutely need it. Make sure that you cancel registration for the latest information once you no longer need it. This helps you avoid unnecessary consumption of battery power or system resources.

 

Second key point: keep blocking operations away from the main user interface thread

 

To ensure that your application runs flexibly, you must use AsyncTask, thread, IntentService, or custom background services to handle dirty work. The loader should be used to simplify the State management of long-time data (such as cursors. You cannot tolerate lag or pause when an operation is being processed by your application.

 

If an operation is time-consuming and resource-consuming, You need to detach the operation and perform asynchronous processing on it, so that your application remains responsive and users can process their transactions. This principle applies to disk read/write, access to content providers, databases and the Internet, as well as resolution and other long-time tasks.

 

Third key point: use the latest Android software development kit (SDK) version, application programming interface (API) and Best Practices

 

Make sure that the applications you develop are up-to-date. Therefore, use the latest tools provided by the Android platform. With the continuous development of the Android platform, it is constantly improving. Some functions may have been deprecated or replaced with better functions. The core API has been corrected (bug fix) and performance improvements. New APIs such as loaders have been introduced to help developers compile and run more stable and responsive applications.

 

Do you know you can enable the hardware acceleration feature in the Android3.0 application? Enable it now! Understand that best practices will change over time. Wise developers pay close attention to the new features of the Android platform and which features are no longer recommended.

 

Fourth key point: consider using the restricted Mode)

 

You can use the AndroidAPI named StrictMode to help you find out what violates several good programming habits. StrictMode will help you confirm whether your application has a memory leak and check whether your application is trying to perform blocking operations for a long time, these operations should be uninstalled to the thread or other channels (refer to the second key point ).

 

Introduce the StrictMode class (android. OS. StrictMode) in Android2.3 ).

 

Fifth key point: Disable or use as little debugging and diagnosis as possible before releasing an application

 

If it takes some time to develop your Android Application, you may have embedded some logs and debugging code into the application. Writing to logs and other such output systems has an impact on performance. Make sure that these features are used or completely disabled as little as possible before releasing the application.

 

 

 

Now let's talk about how to use good user interface design principles to make your application screens load more quickly:

 

Sixth key point: Make sure that your design layout is simple, concise, and shallow

 

A simple screen makes reading easier, while a simple layout makes loading faster. You should not nest your layout too deeply, or fill the screen with unnecessary excessive View controls. It takes some time to develop concise user interfaces that users can use efficiently, rather than trying to plug too many functions into a single screen. This not only improves application performance, but also makes your application more efficient for users.

 

Fragments helps to divide user interface functions without affecting flexible design for different types of devices.

 

7. Point 7: Make your application resources suitable for the target device

 

Add resources suitable for specific device configurations so that they can be loaded as efficiently as possible. This is especially important when talking about graphics resources. If you have added a large number of available image resources and need to load and adjust the size, you will not be able to effectively use other application resources.

 

Another key point is that if you prepare your application to run on many devices, to keep the file size of the application package reasonable, you should first add only the core resources required to run the application, and then let the application download the content suitable for the device.

 

Eighth point: Use the Hierarchy Viewer tool

 

The Hierarchy Viewer tool can help you debug your application layout. It also provides valuable analysis information to understand how much time each view control in the layout takes to measure, render, and draw. It is easy to solve the problem only when the root cause of the problem is found accurately.

 

Ninth point: Use the layoutopt Tool

 

Layoutopt is a simple command line tool that helps you find unnecessary control nesting and other ways to reduce the layout of resources, so as to minimize the use of resources. It allows you to understand which layout controls may be redundant or unnecessary. The fewer controls and the lighter the layout, the better the performance.

 

Finally, do you think your application is the best? Now we have to test it.

 

Tenth key point: Analysis Using Traceview and Other Android tools

 

The Android SDK comes with many tools that can be used to analyze your applications. The most popular tool is probably Traceview, which helps you debug and find performance bottlenecks in applications. Take a look at some debugging tools described in the Android documentation.

 

Conclusion

 

There are many ways to help you improve the performance of Android applications. Some require specific algorithms and some rely on practical debugging and performance monitoring techniques. Fortunately, the Android platform comes with a number of free utility tools to help you identify and eliminate performance problems in applications. Now that you have these tools, you must use them immediately!

From kwon 'blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.