In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to communicate between Activity and Service in Android". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how Activity and Service communicate in Android.
For Service remote calls, it is usually in different projects, that is, two different processes, so what is the communication mechanism of the process? The fool drew a picture to illustrate it.
When communicating remotely, the Android process will:
1. Generate a main thread.
two。 Generate Looper objects
3. Generate a message queue.
4. Generate a virtual machine object to communicate between Java and C++.
5. The remote communication is realized through the IPC of the CumberCraft + layer.
The so-called inter-process communication: Android realizes the communication between processes through the IBinder interface. MyActivity will call the transact () function of IBinder and call the remote onTransact () function through IPC. Note: by default, if Service, Activity and BroadcastReceiver are in the same project, then these components will be executed in the same process and executed by the main thread. Of course, you can also configure them to execute in different components, such as letting Service run in the Remote process.
At this point, I believe you have a deeper understanding of "how Activity and Service communicate in Android". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.