Java. lang. illegalstateexception: the content of the adapter has changed but listview did not receive a notification. make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [In listview (-1, class android. widget. listview)
With adapter (class android. widget. headerviewlistadapter)]
At Android. widget. listview. layoutchildren (listview. Java: 1492)
At Android. widget. abslistview. ontouchmodechanged (abslistview. Java: 1960)
At Android. View. viewtreeobserver. dispatchontouchmodechanged (viewtreeobserver. Java: 591)
At Android. View. viewroot. ensuretouchmodelocally (viewroot. Java: 2087)
At Android. View. viewroot. javasmtraversals (viewroot. Java: 1023)
At Android. View. viewroot. handlemessage (viewroot. Java: 1793)
At Android. OS. handler. dispatchmessage (handler. Java: 99)
At Android. OS. lorule. Loop (lorule. Java: 123)
At Android. App. activitythread. Main (activitythread. Java: 4627)
At java. Lang. Reflect. method. invokenative (native method)
At java. Lang. Reflect. method. Invoke (method. Java: 521)
At com. Android. Internal. OS. zygoteinit $ methodandargscaller. Run (zygoteinit. Java: 868)
At com. Android. Internal. OS. zygoteinit. Main (zygoteinit. Java: 626)
At Dalvik. system. nativestart. Main (native method)
All words start with the exception above.
I. Bug location tracking.
The headache of this exception is that it is impossible to identify the problem from the call chain, and capturing exceptions from the UI tree is not feasible. You can only check where such a UI tree is used, and then determine where the problem occurs. This problem is not just a simple technical problem, because the failure to identify it means that you cannot determine who is responsible. If the owner cannot be defined, the execution will be impossible. This leads to a topic that I want to discuss today and defines the responsibility of the Code.
Ii. Code responsibility definition.
This can be viewed in two aspects. First, before development, the technical architecture of the project should ensure that tasks between personnel are divided into high cohesion and low coupling. The other is when a problem occurs, for example, after the code crashes, it is easy to define who the problem belongs. Today we will focus on the second one.
To quickly define the responsible person after a problem occurs, you can use the following methods:
1. The most common method is to look at the exception chain. This can be done during development. However, the exception detected by the sent obfuscation package cannot be solved.
2. If you want to deal with exceptions after code obfuscation, You need to tag each class and quickly locate the scope of the problem to the class level by searching for tags in the decompiled files, in this way, the owner can be quickly defined. Next, we will further define the specific method for the problem through the number and type of parameters of the method.
3. Special Handling of the aforementioned exceptional exception chain. Check which activity uses this UI tree. Run the footer or Headder of listview in this activity to check whether the operation to modify the adapter data is not put at the beginning of the thread.
I don't know if you haven't noticed it. We can see from that in some aspects of the project, only people with rich experience can have fewer problems, or solve the problem quickly after the problem occurs. This leads to another topic I have come up with. How can I ensure the stability and reliability of the program through methods other than the program.
Iii. Code Review
When executing code review, pay attention to the following operations:
1. Publish standardized code standards and precautions for problems (for example, the cause of the above exception is a bit ).
2. 1 Senior Engineer with 1 ~ Two Junior engineers. Senior engineers are responsible for periodic review of junior engineer code.
3. Periodically review the collective code of the entire project module within the team. One is to supervise everyone to execute code standards, and the other is not detailed in the Code population standards.
The Risk Control of code is a deep learning.