1

I wanted to send location information every 15miutes through service. The problem i faced it, the service get killed once after few hours. So, What am i thinking is to send location information & stop the service & Create it once again after a 15minutes. is it good idea to do that? How it can be accomplished? How it can be accomplished , i don't know exactly how to stop & create service every 15 minutes.

Thanks..

Prem Singh Bist
  • 1,273
  • 5
  • 22
  • 37

2 Answers2

4

You can do this with help of AlarmManager, Reschedule Alarm every time after it invokes that is the best way, as per your scenario. AlarmManager is never killed because it directly connected with System RTC. here is the sample example.

Yuvi
  • 1,344
  • 4
  • 24
  • 46
1

In Android you can use Timer and TimerTask in a Service. Here are some examples

Android - Controlling a task with Timer and TimerTask?

Pausing/stopping and starting/resuming Java TimerTask continuously?

Android Timer within a service

Community
  • 1
  • 1
Siddharth
  • 9,349
  • 16
  • 86
  • 148