Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top