Skip to main content

Android App Performance Optimization

Android App Performance Optimization

Improving Android Application Performance

Creating Apps for the Android OS gives a lot of freedom to developers and access to an ever-growing 
user base to the application owner. However, the developers face numerous Android application 
 development challenges in the process. There is numerous android OS version which developers 
find hard to keep up when it comes to development.
This turns into a major challenge in Android app development since there are nearly 170+ devices 
running the OS. Each device has various highlights with respect to screen size, camera buttons, 
keyboard forms, etc. , making it a development nightmare. Remembering a couple of things we 
can improve the performance of our application. Following are the factors which degrade our app 
performance and the improvements which can be done.

Slow Rendering

Slow Rendering is the widest performance problem. Because what the designers need from us and 
what we do, may not be the same and trying to do the best visuality, we can sometimes fail in 
development.
Rendering is defined in terms of times which ensures that application is running Butterly smooth at 
a constant 60 FPS without any dropped or delayed frames.

What Causes Slow Rendering?

The system tries to attempt redrawn your exercises after each 16ms. This implies that our app has 
to do all the logic to update the screen in that 16 ms.
what if our app can’t complete the logic in 16 ms?
Android App Performance Optimization
It’s called a dropped frame. For instance, if your calculation takes 24 ms, this case happens. The 
system tried to draw a new picture to the screen, but it wasn’t ready. So it did not refresh anything. 
And because of this, the user is looking at the  refreshed picture after 32 ms instead of 16ms. If 
there is even one dropped frame, the animation will begin not to be seen smooth.

The following tools can be used to improve rendering:

Hierarchy Viewer: Hierarchy viewer is a tool built into an Android device monitor that enables 
you to check the features and layout speed for each view in your layout hierarchy. It can enable 
you to discover performance caused by the structure of your view hierarchy, helping you then 
simplify the hierarchy and reduce overdraw.
Profile GPU Rendering: Profile GPU rendering gives a quick visual representation of how long 
it takes to present the frame of the UI window relative to the 16-ms-per-frame benchmark.
Android App Performance Optimization by android training chandigarh
Enable Profile GPU Rendering
  • On your smartphone, go to Settings> Developer Options.
  • In the Monitoring section, select Profile GPU Rendering.
  • In profile GPU rendering popup, choose the bar as the screen
  • Go to the app you want to profile.
Visual Output of GPU Profiler
  • The horizontal axis shows elapsed time, and the vertical axis shows time in milliseconds per frame. 
As you interface with your application, vertical bars appear on your screen.
  • Each vertical bar represents one frame of rendering.
  • The green line marks the 16-millisecond target. Every time a frame crosses the green line, the 
application is missing a frame, and users may consider this as stuttering images.

Application Launching Time

App launch can take place in one of two states, each affecting how long it takes for an application to 
become visible to the user.
  • Cold Start
  • Warm Start
Cold Start: A cold begin refers to an application's beginning from scratch, Cold starts to happen in 
occur in cases, for example, your application's being launched for the first time since the device was 
booted, or because the system killed the app
At the start of a cold start, the system has three tasks. These tasks are:
  • Loading and launching the app.
  • Displaying a blank initial window for the app immediately after launch.
  • Creating the app process.
Warm Start: A warm beginning of your application is a lot easier and lower-overhead than a cold start. 
In a warm start, all the systems bring your activity to the foreground.
If all the activities of your app are still resident in the memory, then the app can avoid repeating the 
objects initialization, layout inflation, and rendering.

How to Resolve the app launching Time delay?

  • Initialize just those objects that are immediately needed. For example, rather than making global 
static objects, instead, move to a singleton pattern, where the app initializes the object for the first time it 
accesses them.
  • Flattening your view hierarchy by reducing redundant or nested layouts
  • Move all resource initializations so that the app can execute it lazily on a different thread. 
  • Allows the app to load and display views, and later update visual properties that depend on 
bitmaps and other resources.
Layouts: The layout is an important part of the Android application that directly affects the user 
experience. If your layout is poorly implemented, then your layout may lead to a memory hungry app 
with a slow UI. Each widget and layout that you include on your application include initial, layout, and 
drawings.  For example, using the nested instance of LinearLayout can have a much darker visual 
hierarchy.

How to Improve Layout Performance?

Optimizing Layout Hierarchies: The use of basic layout structures leads to the most efficient layout. 
However, for each widget and layout you add, initialization, layout, and drawing are required. 
For example, using the nested instance of LinearLayout can have a much deeper visual hierarchy. 
In addition, using the Layout_weight parameter, using multiple instances of LinearLayout can be 
particularly costly because each child should be measured twice. This is especially significant when the 
layout is inflated repeatedly, such as when used in a ListView or GridView.
Re-using Layout with <Layouts>: Reusing layouts is particularly powerful as it permits you to create 
reusable complex layouts. For example, a Yes / No Button panel, or Custom Provincial bar with 
description text. It also means that any part of your application that is common to many layouts can be 
extracted, adjusted separately, then added to each layout.
So while you can make individual UI components by writing a custom View, you can do it even more 
easily by re-using a layout file.
Loading Views on Demand: Some of the time your layout may require complex views that are rarely 
used. Whether they are item descriptions, promotion indicators, or message backs, you can reduce 
memory usage and speed up your progress by loading the views only when they are needed.
Power Usage: Reducing battery usage is an important part of Android's development because this 
optimization will ultimately lead to retain the user because sometimes the applications are uninstalled 
due to battery drain issues.
  • Tips for improving battery use in Android apps:
  • Reduce network calls as much as you can.
  • Avoid wake lock as much as Possible.
  • Use GPS carefully.
  • Use Alarm manager carefully.
  • Perform Batch Scheduling

Comments

Popular posts from this blog

The best PHP IDE development tools that every developer should explore

Best PHP IDE development tools that every developer should explore The best PHP IDE: Basically, to learn good programming skills in PHP or any other language, you must have known  the best PHP IDE, development tools or editors. There are many lists for PHP IDEs or code editors, but some of them are amazing and very useful for writing code. Basically, the best PHP IDE comes with many features and skills to do  things with the use of PHP programming support. PHP has many options in each field. It gives you the best. Therefore,  we want you to choose the best PHP IDE for your own operator. As always I used a line "Your life is your choice".  But I suggest you select better, Easy and Free. Read also: CMS or PHP framework How do we define a PHP IDE, PHP development tools or editors is the best? Basically, according to me, I have some parameters in which I select a PHP IDE or an editor that is listed below. Price (Free or Paid) Theme (color scheme) ...

Main update of the Cisco CCNA, CCNP, CCIE certification - Changes in 2020

Main update of the Cisco CCNA, CCNP, CCIE certification - Changes in 2020. In this post, you will learn about the main updates that will come to the Cisco Certification Program in February 2020 . CCNA training in Chandigarh blogger will explain exactly what the changes are, why Cisco has made them, how they affect you and what you should do if you are currently studying or You are considering starting to get a Cisco certification . Summary of the Main Changes The changes will take effect on February 24, 2020 All tracks and certification levels are affected The main levels of certification remain the same: CCNA, CCNP, and CCIE The different tracks are being eliminated at the CCNA level The tracks are consolidating at CCNP and CCIE level CCENT entry-level certification is being retired The recertification period for all certifications will be 3 years CCNA Cisco Certified Network Associate Current CCNA Tracks before February 24th: CCNA Routing and Switching CCNA C...

What is PHP in Web Hosting?

What is PHP in Web Hosting? In this Article PHP training in Chandigarh provide the information about PHP in web hosting. PHP in web hosting is a server-side computer language used to arrange the display and functionality  of web pages. The term “PHP” is an abbreviation for the term “ PHP Hypertext Preprocessor .” The  PHP language is open source and free to use, not at all like proprietary web programming languages,  for example, ASP and C#. Proprietary languages must be interpreted by authorized server software,  For example,  Windows Server, whereas PHP keeps running on open source servers, such as  Apache. However,PHP can keep running on exclusive web servers too. PHP code pages can be  recognized by the ".php" file extension, according to PHP.net. A significant number of the open source web applications, for example, WordPress,  Joomla and  Drupal are written in the PHP language. Also, open source ecommerce packages li...