I am new to Android SDK/API environment. It's the first I am trying to draw a plot/chart. I tried running different kinds of sample codes the emulator using 3 different free libraries, nothing is showing in the layout screen. The logcat is repeating the following message:
W/Trace(1378): Unexpected value from nativeGetEnabledTags: 0 I/Choreographer(1378): Skipped 55 frames! The application may be doing too much work on its main thread.
The problem didn't persist and the chart worked when I ran a sample code pertaining to an evaluation copy of a licensed library.
I am not an expert, but I got this debug message when I wanted to send data from my android application to a web server. Though I used AsyncTask class and did the data transfer in background, for getting the result data back from server I used get() method of the AsyncTask class which makes the UI synchronous which means that your UI will be waiting for too long. So my advice is to make your app do every network oriented tasks on a separate thread.
Another common cause of delays on UI thread is SharedPreferences access. When you call a
PreferenceManager.getSharedPreferences
and other similar methods for the first time, the associated .xml file is immediately loaded and parsed in the same thread.One of good ways to combat this issue is triggering first SharedPreference load from the background thread, started as early as possible (e.g. from
onCreate
of your Application class). This way the preference object may be already constructed by the time you'd want to use it.Unfortunately, sometimes reading a preference files is necessary during early phases of startup (e.g. in the initial Activity or even Application itself). In such cases it is still possible to avoid stalling UI by using
MessageQueue.IdleHandler
. Do everything else you need to perform on the main thread, then install the IdleHandler to execute code once your Activity have been fully drawn. In that Runnable you should be able to access SharedPreferences without delaying too many drawing operations and making Choreographer unhappy.Try to use the following strategies in order to improve your app performance:
I had the same problem. In my case I had 2 nested Relative Layouts. RelativeLayout always has to do two measure passes. If you nest RelativeLayouts, you get an exponential measurement algorithm.
I too had the same problem.
Mine was a case where i was using a background image which was in drawables.That particular image was of approx 130kB and was used during splash screen and home page in my android app.
Solution - I just shifted that particular image to drawables-xxx folder from drawables and was able free a lot of memory occupied in background and the skipping frames were no longer skipping.
Update Use 'nodp' drawable resource folder for storing background drawables files.
Will a density qualified drawable folder or drawable-nodpi take precedence?
First read the warning. It says more load on main thread. So what you have to do is just run functions with more work in a thread.