Actually, it would be fairly easy to do this, but I don't think there
is an existing method for it.

First, create some kind of flag in the Service to represent whether
it's running. Update this flag in onStart and onDestroy. Then provide
a public static method to access this flag. I would be tempted to use
a static boolean flag, but I'm under the impression that gets wiped
out if the system decides to stop your Service when trying to free
resources. Maybe someone will clarify that. If it doesn't get wiped,
I'd do that. If it does, you could probably save/load the status using
preferences or a file.

On Apr 12, 2:27 am, "Harsh Jain" <[EMAIL PROTECTED]> wrote:
> I remember hackbod saying sometime back that you cant do this. But please
> search the forums.
>
> harsh
>
> On Sat, Apr 12, 2008 at 6:33 AM, Soonil Nagarkar <[EMAIL PROTECTED]> wrote:
>
> > As the subject states, I want to check if a Service is already
> > running. If it is not, I do not want to start it, and if it is I want
> > to stop and then start it again. How can I find this out? Thanks -
> > Soonil N.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to