UrbanPro
true

Learn Android Application Development Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Android : Application Launch time improvements.

Gaurav Bansal
10/01/2017 0 0
For any standard android application, below 3 components play important roles to show 1st interface to user, so that he/she can interact with the app.
1. Custom Application class : Intialize the components which are going to be used for the all application components such as activities or views.
2. Splash Screen : It is the first UI which is displayed to the user, in the background of which, we initialize those components which are required for Main Activity (mentioned below) to show data
3. Main Activity : This is the home screen where major data is displayed using views and fragments.
To avoid delay in Launch, we can consider below few fixes.
a) There should be minimal functions in onCreate() method of above 3 components. Although when we check the time taken in onCreate() to be completed, it shows less time, but the component which you have initialised, will take some time to give result e.g. inflating layouts or initialising a third party SDK.
b) Instead of writing initialisation of 3rd party SDKs in your Application class, put them whenever they are first needed. e.g. Facebook or Google Login SDKs
c) Move the loader or inflater related to UI in your Main Activity instead of Application class as during app initialisation we are not showing any UI e.g. Notification count to show the bubble in Main Activity
d) Do the heavy work on the thread which are neither related to UI nor for immediate requirement. a thread can be started in Application class too if required.
e) In general, Splash is launched and we launch main activity after a certain time in Handler object using postRunnable. Instead of that we have to do heavy task in thread and on completion of that thread, we have to launch the Main Activity on Main thread as below:
Thread splashSetupThread = new Thread(new Runnable() {
    @Override
    public void run() {
 
    //Here do all the work not related to UI
    //after finish launch home screen in main thread as below
 
    runOnUiThread(new Runnable() {
    @Override    public void run() {
        launchHomeScreen();
    }
});
 
F) There can be some UI elements in the Main Activity which can be shown after main UI component is shown e.g. A mini player in a Music application can be displayed once the songs and albums are displayed to the user. So do not write the code of those UI elements into the onCreate of Main Activity , instead write them in onWindowFocusChanged() as below:
 
@Overridepublic void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if(onCreateCalled && hasFocus) {
        onCreateCalled = false;
        //write UI element inflation code
    }
}
 
If above steps are followed then certainly launch time will be reduced.

Question ? Please comment !!!
0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Big Data Hadoop Training
What is Big Data? Big data means really a big data, it is a collection of large datasets that cannot be processed using traditional computing techniques. Big data is not merely a data, rather it has become...

10 Cool SQL Optimizations That Do Not Depend On The Cost Model
Today, we don’t want to talk about cost based optimisation, i.e. optimisations that depend on a database’s cost model. We’ll look into much simpler optimisations that can be implemented...

Puzzle Game coding
import java.awt.BorderLayout;import java.awt.Color;import java.awt.Dimension;import java.awt.Font;import java.awt.FontMetrics;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.RenderingHints;import...

Android App Design
Now a days you can't just put logic (or functionality) in your app with a normal UI and hope to make it a success. Functionality is something which everyone provides depending on app features but to make...

Why Should We Learn Java Language?
Most of starters has confusion today that which of the programming language should be chosen to work on. It totally depends upon your need. As per my opinion, if you want to grow your career in IT industry...
X

Looking for Android Application Development Training Classes?

The best tutors for Android Application Development Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Android Application Development Training with the Best Tutors

The best Tutors for Android Application Development Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more