The communication mechanism of the Binder is simple, but some problems have been encountered in the use process. Finally, we have solved the problem. Here we will summarize the problems and share them with you:
1. To use Binder for communication, first define the interface, and then implement the BnInterface *** on the server and the client BpInterface ***. In the end, one is to unpackage the parameters, and the other is to package the parameters.
2. The server must be able to receive the Binder call request with two conditions: one is to implement the Bn interface, and the other is to call IPCProcess ()-"self-> startThreadPool () www.2cto.com
IPCThread ()-> Self-> joinThreadPool ();
These two statements are very important, because he started a thread in the background and was responsible for reading the request called by the Binder interface and then calling the specific interface. If this thread is not available, your service cannot receive the call request, and the client fails to call (died ).
The same applies to clients. To support callback, you must start the thread that reads the Binder call. Otherwise, the callback fails.