Android Specific Value Import Service Runs Every 1 Minute

Asked 1 years ago, Updated 1 years ago, 126 views

One of the application functions I'm working on is to activate and maintain the service from the first launch of the app. The function of this service is to get the db value by doing web communication every 1 minute. However, I can't figure out how to continue activating the service from the first run of the app, and I can't figure out how to run it periodically in the background every minute. I'd appreciate it if you could tell me the solution.

background android service

2022-09-22 21:35

1 Answers

If the requirement is to read data from the server every one minute from the initial launch of the app to the end of the app, declare the child class that inherited the application and register it with Manifest,

In the onCreate method of the application, you can request data from the server every 1 minute using the Timer class.

Http communication-related libraries are easy to work with Retrofit, and when delivering the results to Activity or Fragment, you can easily call back using Otto's library called EventBus.


2022-09-22 21:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.