Analysis of real-time data transfer from service to activity in Android
This article describes the method of real-time data transfer from service to activity in Android. Share with you for your reference. The details are as follows:
Here is a case. The requirements are as follows:
Create a thread in the service component, which is used to produce the value. The value will be automatically increased by 1 every 1 second, and then the updated value will be displayed in real time on the interface.
The steps are as follows:
1. Create an Android project named demo.
2. Create a new service class to produce values in real time for real-time display on the interface.
3. Create a new activity class to display data.
4. Main.xml layout file
5. Manifest file
The effects are as follows:
I hope this article will be helpful to your Android program design.