开发者

Running a function in an android application, which runs in the background whenever the program is running and when the application is paused

开发者 https://www.devze.com 2023-03-17 23:52 出处:网络
I am trying to gather access point data from an android phone on a time interval about every minute for a certain am开发者_JAVA百科ount of time. I already can gather data but I am only able to gather

I am trying to gather access point data from an android phone on a time interval about every minute for a certain am开发者_JAVA百科ount of time. I already can gather data but I am only able to gather the data once the application is started. What I have no clue on doing is somehow creating a background service which runs for a certain amount of time and executes a function in a time interval of about one minute.

Thanks for your help


Try the following steps:

  1. Create a background service.

  2. Create a class which extends TimerTask. This class will contain code to fetch accesspoint details and also notify accesspoint details to your service.

  3. Create an interface.

  4. Register that interface for your service and then implement this interface in your service.

  5. In your oncreate method schedule the TimerTask class to be executed for certain interval and also notify accesspoint details to your service class.

0

精彩评论

暂无评论...
验证码 换一张
取 消