0

My application is a GPS tracking, after every 2 mins, the latitude and longitude are stored into database. If user manually stops the application from

settings->manage application->our app --->Force stop

I need to start the app again. Is it possible?. Google play service starts again ,if we force stop the application. Why this one is possible?

CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
vani
  • 5
  • 2
  • 3
  • I tried force stopping the Google Play app and then I couldn't see Google Play Service running anymore. – pree Sep 25 '13 at 17:27
  • in samsung GT-S5360 mobile, if i stop the Google Play Service, it automatically start the service again. – vani Sep 26 '13 at 04:38
  • Interesting. I tried it on HTC One. It's been one full day since I killed the Google Play service/app and it hasn't started till now. – pree Sep 26 '13 at 17:31
  • refer this answer : http://stackoverflow.com/questions/12672438/start-service-after-force-stop/20093158#20093158 – Beep.exe Nov 20 '13 at 10:45

1 Answers1

5

I'm not sure why would you want the service to start if the user explicitly chooses to kill the app. However, you can auto start the service at boot time. Refer link: Android -Starting Service at Boot Time

Community
  • 1
  • 1
pree
  • 2,297
  • 6
  • 37
  • 55
  • thank you for reply. our needs to continuously take the GPS with particular time. so i need to start again if user manually stop the application. yes i added android-starting service at boot time. – vani Sep 26 '13 at 05:08
  • Okay, I see but when user tries to force stop a service, it always warns the user about the app failure. However, if the service crashes on its own, you can choose to auto restart it by specifying START_STICKY mode. Also, as I mentioned above, Google Play app doesn't auto restart on HTC one. So it's better if you take that variable into account. Each device may have a different behavior. – pree Sep 26 '13 at 17:42
  • Okay, i have used START_STICKY mode. but its not use, while user manually stop the application from settings-->manage application--->Our app-->force stop., Service doesn't start again.but while screen off, services start again beacause of START_STICKY mode. – vani Sep 27 '13 at 05:14
  • START_STICKY wouldn't start the service if user killed it. What I meant was you can make sure that service keeps running as long as user doesn't manually kill it. Also, please refer this link: http://stackoverflow.com/questions/17022985/restart-service-after-force-stop – pree Sep 28 '13 at 00:01