I am developing an simple android application ( studying ). The application will send a "I am online" detail to the server at the interval of 15 mins. The application view consists of only one button. On this button click, I need to close the application view and run the application in background and send request to sever at the interval of 15 mins.

I developed the application and webservices. But still confused how to make the application as background process ..

Please anyone advise Thanks in advance

有帮助吗?

解决方案

Get familiar with AlarmManager for scheduling events according time. And Service for background work. So the idea is to schedule event for 15 minutes after user press button. Once callback received you can start service that will send request to the server.

Use setRepeating in AlarmManager for schedule on each 15 minutes and cancel for stop scheduled event.

Create new service that will perform web request and start it from BroadcastReceiver that receive event from AlarmManager.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top