I’ve tried to have any of my processes inside my App in a seperate thread from „Main-UI-Thread“.
There was only one strange thing to see on the logcat message view:

Choreographer(abc): Skipped xx frames! The application may be doing too much work on its main thread.

This message says that there is done some work in the „Main-UI-Thread“, but in my sight it can’t be possible. There is a short statement to check whether the your function runs inside the „Main-UI-Thread“:

if(Looper.myLooper() == Looper.getMainLooper())
    Log.i("DEBUG", "running in Main-UI-Thread");

This statement helped my realy fast to find the issue. It was on my receiving thread. But in knowledge don’t to do much work or blocking processes inside the „Main-UI-Thread“ if defined and started a seperate thread for it:

new ReceiveThread.run();


And here you can see the issue. It must be:

new ReceiveThread.start();

Both versions are running the thread. The first one reports the log message you can read in the beginning of this post, the seconds works as expected. If you read the documentation you find the explanation for the behaviour.

Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.



Hopefully you don’t ran inside the same problem. It costed me several hours of work to locate my issue. The receiving thread worked as expected while I not trying output anything on the UI. The logcat received every of my messages I wanted to see.
I thought my problem was somewhere at my handler funciton.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert