I was asking more along the lines of "what is your service actually doing". What is its purpose that requires this limitation? Is it a long-running task it's executing or something quick?
In any case, on further thought: Service.onCreate() should only be called if the service is not already running, so you can use that to your advantage. So from your activity, always call startService(), the activity won't care if the service is running or not, it'll be up to the service to do the right thing. If the service is not started, onCreate will be called and you can start your work from there, then onStartCommand gets called, which you can ignore. If the service is started, onCreate will NOT be called, the work will NOT be restarted, and onStartCommand will still be called, which you can again ignore. On Fri, Jan 31, 2014 at 11:00 AM, dashman <[email protected]> wrote: > Absolutely - happy to explain. >> > > My service can be started at phone bootup - works wonderfully. > > Now when the user starts my app (Activity) - in the onCreate method > i want to see if the service is running - if not running - i want to run > it. > > I've taken your advice and in the Activity.onstart/onstop - i bind to the > service. > (works fine) > > > The problem is that in the activity.onCreate() method when i call > startActivitry() - > > it calls the services onCreate() and onStartCommand(). > > I'm thinking that it deletes the running service (even though the > onDestroy() does not seem > too called - and then creates a new service object - explained by the > above 2 calls. > > > Basically, in the Activity.onCreate() - I'd like to launch the service if > it's not running. > > > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Android Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- ------------------------------------------------------------------------------------------------- TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

