Android uses files for IPC
1、 Document for IPC introduction
Sharing files is also a good way of inter process communication. Two processes exchange data by reading / writing the same file. On windows, if a file is locked with an exclusive lock, other threads will be unable to access it, including reading and writing. Because Android system is based on Linux, concurrent reading / writing of files can be carried out without restrictions. Even two threads are allowed to read and write the same file at the same time, although this may cause problems. Data exchange through files is very useful. In addition to exchanging some text information, it can also serialize an object into the file system and recover the object from another process.
2、 Method of use
1. The data class implements the Parcelable or serializable interface
2. Serialize an object into a file on the SD card
3. Deserialize in another process
4. Start multiple processes in androidmanifest.xml
3、 Small case
1. Modify activity_ Main.xml file
2. Add activity_ Second.xml file
3. Add myutils class and myconstants class (auxiliary class)
4. Add user class
5. Add the secondactivity class
6. Modify mainactivity class
7. Modify the androidmanifest.xml file
Full code download address: https://github.com/ZhangMiao147/IPCDemo
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.