-2

I have created the service and its working fine while application is running. Service will stop when application instance closed. I resolved this issue by calling service from GCM notification appears and its not stop until the service operation complete.

But, Its not working locally even I am sending the local notification, Please anybody help to run the service in background even application closed .

Ramesh
  • 27
  • 8
  • What do you mean by "sending the local notification"? – 0x6C38 May 29 '16 at 04:16
  • Can you be more specific? It is unclear as to what you are trying to achieve. Plus posting code where you think your error is will also help a lot. – Aradhna May 29 '16 at 04:28
  • When I calling service when GCM notification appear, its working and not stop even app closed. When I send the local notification then service stop when application closed – Ramesh May 29 '16 at 04:45

2 Answers2

0

Try startForeground(int, Notification) and stopForeground(boolean removeNotification) method as given on this Link.

0

You can declare your service as START_STICKY. There is tons of information out there about this on Google for you to use. Hope this helped!

Ethan
  • 1,905
  • 2
  • 21
  • 50
  • Thanks Dude, I had implement START_STICKY but its not working when application closed. – Ramesh May 30 '16 at 04:40
  • Try this: http://stackoverflow.com/questions/12470967/how-to-make-an-application-run-continuously-in-android – Ethan May 30 '16 at 15:30