Android and Lag Time – Time to Shoo It Away

Android lag can give a hard time to users while uploading files or doing anything on the app. Think about it. The app opens up slowly and works with a lot of pause. The only option to speed up is rebooting. It’s simple.

Android app developers must create responsive apps for users to give them the best experience. Few things stated below can be put in progress to do the same. Most Android users today complain of an Android lag time. The lag time is apparent when switching between apps, opening a new app or when the storage capacity of the device goes near full.

Android Lag Time

Efficient Codes and Creating Worker Thread
Efficient coding practices can eliminate lag time. However, sometimes even the most efficient codes cannot resolve it. Therefore, App entrepreneurs should see the method running on UI thread should do minimal work on that thread as far as possible. Moreover, on the worker thread, the database or network operations and expensive calculations like resizing bitmaps which takes long time to run should be executed.

How To Do It?
To create worker thread, is important for long running operations which can be done with the AsyncTask class. The app creators need to extend the AsyncTask and then execute the doInBackground() which helps to perform work. For posting the progress changes the App creators can implement publishProgress() that invokes the call back method. The progress update can notify the user then. The thread should be set to lower priority for smooth operation of the App. You should also lay emphasis on the UI thread which must not halt the worker thread completion. The Handler should be provided to the main thread to post back on completion. So, this method will keep the app responsive and also avoid ANR (Application Not Responding) dialog. If it is a games app, then one needs to calculate the moves in the workers thread so there is no lag time.

Working In Harmony with Broadcast Receiver
The Broadcast Receiver performs work on the background where it saves the settings and registers a notification. So operations which take a long time to execute must not be run in the Broadcast Receiver, so only small amount of work must be performed on this and in case long running actions needs to be taken, then the Intent Service should be started. This will help to get rid of lag time.

Other Things to Implement
The App creators can make use of the tools like, Traceview and SYstrace that will check the congestion in the apps performance and help to create a more responsive app.


Please enter your comment!
Please enter your name here

Stay Techdated

Where technology news gets delivered to you. Subscribe to and get juicy tech updates in your inbox without having to search or scroll for them elsewhere.

Latest stories

You might also like...