0

I have a class extends Service on my app. It works whole day without stopping.But, logs shows that in the morning Service starts unexpectedly and logs are exist in the onCreate method, not onStartCommand methods logs. Anyone help?? Thanks in advance.

nAkhmedov
  • 3,522
  • 4
  • 37
  • 72
  • I suggest you to refer this question: http://stackoverflow.com/questions/14182014/android-oncreate-or-onstartcommand-for-starting-service – rusted brain Mar 10 '16 at 06:09
  • @Diffy When you call startService(), if the service is not running, Android will create an instance of the service class (this is a service object) and will then call onCreate() on that object. It will then call onStartCommand() on that object. If, some time later, you again call startService(), if the service is still running, Android will not create a new service object. Instead, it will just call onStartCommand() on the existing service object. Is that clear? – David Wasser – nAkhmedov Mar 10 '16 at 06:33
  • I know after calling onCreate method OS should call onStartCommand method. But it doesn`t work on me once? – nAkhmedov Mar 10 '16 at 06:34
  • Try calling your service with an action http://stackoverflow.com/a/24730519/3496570 – Zar E Ahmer Mar 03 '17 at 07:49

0 Answers0