Thanks for all your help. I was afraid that the only way to accomplish
this would be to track its status on disk, which is really kinda
nasty. A feature like this would be really useful since I don't want
to start/stop a service if I really don't have to. I'm sure there are
some security implications though, and I guess the Android team will
have to balance those. Ah well, c'est la vie. -Soonil N.

On Apr 12, 3:08 pm, "Dan U." <[EMAIL PROTECTED]> wrote:
> 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 [email protected]
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