문제

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