• Register
0 votes
393 views

Problem :

I am beginner to Android Programming I am trying to draw the plot/chart for the very first time. Currently I am running different kinds of sample codes and my emulator is using three different types of free libraries but nothing is apearing in the layout screen. My logcat is repeating the below 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.

How can I fix this issue?

8 4 2
2,300 points

2 Answers

0 votes

Solution :

I had faced this “Skipped 55 frames!" error in the recent past it means some heavy processing is going on in your application.

In my case there was not a single heavy process running in my application. So I just double checked everything and I tried to remove those process I thought were a bit heavy.

So I started removing the Fragments, Activities, and also Libraries until only my skeleton was left. But still my problem did not got fixed then I decided to check my resources and to my surprise I found some icons and backgrounds which I was using were very big as in hurry I forgot to cross check their size..

So I can tell you that if you are facing above issue then you must first check your resource files size.

5 2 1
4,980 points
0 votes

Solution:

To avoid that the listview component

public async Task Async_llenarListView(){
await Task.Run(() => {
string[] _equipos = { "Los Angeles Lakers", "Golden State Warriors", "Boston Celtics"};
for (int i = 0; i < _equipos.Length; i++){
                _lista.Add(new model_equipos{
                    _id = i,
                    _source = "team" + (i + 1),
                    _nombreEquipo = _equipos[i],
                    _siglas = _siglas[i],
                    _votos = new Random().Next(0, 100) + ""
                });
            }
        });
    }`

To call a Page

private void mc_btn_sinCuentaAsync(object obj){
Application.Current.MainPage.Navigation.PushAsync(new mdp());
}

Wiht the slow scroll you used the ListViewCachingStrategy and set them with RecycleElement. And may be your ListView Scroll have a fluid scroll now.

I solved this problem by changing in Manifest file hardwareAccelerated option to true like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapplication">

    <application android:hardwareAccelerated="true">
        ...
    </application>
</manifest>

Fixing this requires identifying nodes where there is or possibly can happen long duration of processing. The best way is to do all the processing no matter how small or big in a thread separate from main UI thread. So be it accessing data form SQLite Database or doing some hardcore maths or simply sorting an array – Do it in a different thread

Now there is a catch here, You will create a new Thread for doing these operations and when you run your application, it will crash saying “Only the original thread that created a view hierarchy can touch its views“. You need to know this fact that UI in android can be changed by the main thread or the UI thread only. Any other thread which attempts to do so, fails and crashes with this error. What you need to do is create a new Runnable inside runOnUiThread and inside this runnable you should do all the operations involving the UI. 

So we have Thread and Runnable for processing data out of main Thread, what else? There is AsyncTask in android which enables doing long time processes on the UI thread. This is the most useful when you applications are data driven or web api driven or use complex UI’s like those build using Canvas. The power of AsyncTask is that is allows doing things in background and once you are done doing the processing, you can simply do the required actions on UI without causing any lagging effect. This is possible because the AsyncTask derives itself from Activity’s UI thread – all the operations you do on UI via AsyncTask are done is a different thread from the main UI thread, No hindrance to user interaction.

10 6 4
31,120 points

Related questions

0 votes
1 answer 48 views
48 views
Problem : I have tried to built a simple music player in Android. My view for each song contains the SeekBar. It works fine for me. Now I want the timer counting the seconds/minutes of a progress of a song. So I put the TextView in a layout, get it with the ... doing with my SeekBar - creating a view in onCreate, then just touching it in run() &ndash; and then it doesn't give me any complaint.
asked Jan 28 jwilliam 3.9k points
0 votes
1 answer 81 views
81 views
Problem : I am facing error on below step objUDMCountryStandards.Country = txtMySearchCountry.Text.Trim() != string.Empty ? txtMySearchCountry.Text : null; in the get grid data throws error as below : &ldquo;The calling thread cannot access this object because a different thread owns it.&rdquo; Is there anything wrong with my code?
asked Jan 7 alecxe 7.5k points
1 vote
1 answer 32 views
32 views
Problem : In the following step objUDMCountryStandards.Country = txtSearchCountry.Text.Trim() != string.Empty ? txtSearchCountry.Text : null; in get grid data throws the exception as below : The calling thread cannot access this object because a different thread owns it. What is wrong in my code?
asked Dec 28, 2019 alecxe 7.5k points
0 votes
2 answers 43 views
43 views
Problems: I am new, I need help, can anyone help me? Applications on the android os are mostly written in what programming language?
asked Feb 14 maddi86 5.4k points
0 votes
1 answer 149 views