10 major points to improve Android application development performance

Source: Internet
Author: User
Tags resource

While Android smartphones and tablets are running faster than a day, developers must keep in mind that the apps they develop are still operating in a resource-intensive environment that relies heavily on batteries and processors whose performance is unmatched by the latest desktop or laptop computers. Here are some ways to help your application "slim down" or "Android to boost development performance" so that they run the most smoothly on Android devices today and tomorrow.

Let's start with a few programming essentials to ensure that your application responds quickly.

  First point: Have good programming habits first

To be an excellent resource manager, use common sense and generally accepted algorithms and standard design patterns. In terms of resource usage, if you open the resource, remember to close the resource. Get as late as possible and release as early as possible. These long-standing programming guidelines also apply to your Android applications, especially if they use the underlying device services.

For example, suppose you write an application that relies on location-based services. Unless you absolutely need to, do not start registering, get the latest location, and make sure that once you no longer need this information, you should cancel the registration of the latest information. This will help you avoid unnecessarily consuming device batteries or consuming system resources.

  Second point: Keep the blocking operation away from the main user interface thread

To make sure your application is flexible to run, use Asynctask, threading, Intentservice, or custom background services to handle dirty work. You should use a loader to simplify the state management of data that is loaded for a long time, such as cursors. You cannot tolerate that your application lags or pauses when an operation is being processed.

If an operation is time-consuming and resource-specific, it is necessary to uninstall this part of the operation and asynchronously process it so that your application remains responsive and the user can handle their transactions. This principle applies to the following operations: Disk reads and writes, access to content providers, databases and the Internet, and parsing and other long-running tasks.

  Third point: Use the latest Android software Development Kit (SDK) version, application programming Interface (API), and best practices

Make sure that the application you develop is up to date, so use the latest tools available on the Android platform. As the Android platform continues to evolve, it is constantly improving. Some features may have been deprecated or replaced with better functionality. The core API has been revised (bug fix) and performance improvement. New APIs, such as loader, have been introduced to help developers write applications that run more stably and respond more quickly.

Did you know that you can enable hardware acceleration in the Android3.0 application? Just let it go! Understand that best practices change over time. Smart developers pay close attention to the new features of the Android platform and the features that are no longer recommended.

  Fourth point: Consider using restricted mode (Strict mode)

You can use the ANDROIDAPI named restricted mode (Strictmode) to help you find out where a few good programming habits are being violated. Strictmode will help you verify that your application has a memory leak and that your application is attempting to perform a lengthy blocking operation that should be unloaded to threads or other channels (see the second point).

The Strictmode Class (Android.os.StrictMode) is introduced into the Android2.3.

  Fifth point: Disable or Minimize debugging and diagnostics before publishing the application

If your Android app takes some time to develop, you may have embedded some log and debug code in your application. Writing to logs and other such output systems has an impact on performance. Make sure that these features are minimized or completely disabled before the application is published.

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

  Sixth point: Make sure you design a simple, concise and shallow layout

Simple screens help to read the most easily, and simple layouts are the quickest to load. You should not embed your layout too deeply, or fill the screen with unnecessarily excessive view controls. Instead of trying to cram too many features into a single screen, take the time to develop a concise user interface that users can use efficiently. This not only helps to improve the performance of your application, but also helps make your application more efficient for users.

Helps to divide user interface functionality without affecting the flexibility to design for different types of devices.

  Seventh point: Make your application resources fit into your target device

Add resources that are appropriate for a specific device configuration so that they can be loaded as efficiently as possible. This is particularly important when we are talking about graphical resources. If you add a large amount of available image resources and need to mount and resize, you cannot effectively use other application resources.

Another important point is that if you are preparing your application to run on many devices, you should initially add only the core resources needed to run the application and then have the application download the content that is appropriate for the application package file to maintain a reasonable size.

  Eighth point: Using the Hierarchy Viewer tool

The Hierarchy Viewer tool can help you debug your application layout. It also provides valuable analysis information to understand how long each view control in the layout takes to measure, render, and draw. Only by finding the root of the problem accurately can the problem be solved easily.

  Nineth point: Using the Layoutopt tool

The Layoutopt tool is a simple command-line tool that can help you find unnecessary control nesting and other ways to reduce layout resources in order to minimize the use of resources. It allows you to understand which layout controls may be superfluous or unnecessary. The less control, the lighter the layout level, the better the performance.

Finally, do you think your application is doing the best you can? Now it's time to test it.

  Tenth point: Using TraceView and other Android tools for analysis

The Android SDK is accompanied by a number of tools that you can use to analyze your application. One of the most popular tools I'm afraid of is TraceView, a graphical tool that can help you debug and find performance bottlenecks in your application. Take a look at some of the debugging tools that are covered in the Android documentation.

  Conclusion

There are a number of ways to help you improve the performance of your Android application. Some need to use specific algorithms, some rely on practical debugging and performance monitoring techniques. Fortunately, the Android platform is full of free utilities to help you identify and eliminate performance problems within your application. Now that you have these tools, you should use them immediately!

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.