The application may be doing too much work on its main thread

前端 未结 17 1844
挽巷
挽巷 2020-11-21 07:34

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 fre

17条回答
  •  离开以前
    2020-11-21 08:04

    this usually happens when you are executing huge processes in main thread. it's ok to skip frames less than 200. but if you have more than 200 skipped frames, it can slow down you're application UI thread. what you can do is to do these processes in new thread called worker thread and after that, when you want to access and do sth with UI thread(ex: do something with views, findView etc...) you can use handler or runOnUiThread(I like this more) in order to display the processing results. this absolutely solves the problem. using worker threads are very useful or even must be used when it comes to this cases.

提交回复
热议问题