Android ANR issue, AsyncTask
So, after making all of my calculations an AsyncTask for my app and leaving the UI changes until the onPostExicute method I realized that my app gets a ANR from even just initializing all of the开发者_C百科 variables for my class which creates my AsyncTask. Here is the code I'm talking about:
http://pastebin.com/BB8M9afE (the things in notes are pieces of code I'm playing with)
If you need more of the code, I can post it. How can I keep my threading class from causing an ANR?
Code Notes: ColorFloodGame(6,6) fills an array of int's with math.random() values. GuiThreader creates a ColorFloodGame(6,6) and makes it an alias of the one in "Play" as well as creating a GUI driver which does the same
Use "adb shell cat /data/anr/traces.txt" to see the stack crawls of the last ANR. The first stack in the list is for the main thread of your app, so it shows what it was doing when the ANR happened. Look at where it was to determine what you are doing that takes so long.
精彩评论