Android development error notes

 1. Registering an event for a control that is not assigned a value will cause a runtime error, and the compiler will not report an error during compilation.
2. When comparing two String type object variables, you cannot use "==" and you should use the .equals() method
3. {"d":0} similar to this is json 
4. Blocking operations cannot be placed in the UI thread, and a separate thread operation is required. 
5. The communication between the thread and the UI thread needs to be carried out by Handler, during which the UI thread corresponds The class must include the CallBack interface 
. 6. Use extens for inherited classes and implements
for inherited interfaces.  7. When String is null, you can’t participate in equals comparison and the program will crash.  
8. If you don’t add permissions, the program will crash. At this time, you need to pay attention to the logcat error
9 .findViewById will return null and the program will crash at this time. Generally returning null is to find an id that is not in the current layout file.
10. Kugou  concert occupies the port of eclipse, so you need to open eclipse before you can open Kugou, otherwise You need to log out frequently to solve the problem of adb need restart
11. When importing external packages, be sure to pay attention to whether there are other folders similar to x86 arm64 armeabi mips, etc., and copy them to the libs of the project to run without error
12. If If the parameter requires a context environment, try to pass the class name of this window. This uses getApplicationContext() as little as possible to use the
L format in the parameter 13.TLV to hex, and only
transfer custom data between 8583 packets and 14.activity. Need to implement Serializable or Parcelable interface 
You can use bundle putSerializable (String, Serizlizable) data or directly use intent putExtrr (String, Serizlizable) data. 
I have a requirement to pass multiple custom data types, so I wrote a data class Value to encapsulate the custom data I need. This class implements the Serizlizable interface. But an error occurred during putExtra. 

Later, I found that in order to transfer data between activities, all content must implement the serializable interface, and a custom type data encapsulated in my Value did not implement this interface, so an error occurred. 
After I let that custom type implement the serializable interface, there is no problem.

The class used for serializable must fail to include Drawable
 
 

Guess you like

Origin blog.csdn.net/zhengjian1996/article/details/112918476