How to list the background service

by ming ming » Sat, 24 Apr 2010 01:48:56 GMT


Sponsored Links
 I like to check my service status, e.g. live or be killed.
so, I hope there is a command like "ps -ef " of linux.

Thanks,
Ming Ming

--



How to list the background service

by krox » Sun, 25 Apr 2010 04:25:58 GMT


 Hi!

Not sure if this is what you are looking for but you can get a list of
all running services by using:

ActivityManager am =
(ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningServiceInfo> runningServices =
am.getRunningServices(1000);

then just loop through that list to see if your service is running i.e

count = runningServices.size();
Component cnMyService = new ComponentName(this, myService.class);
(for int i=0; i < count ; i++) {
   if( runningServices.get(i).service.equals(cnMyService) )  {
      // Your service is running, do something
   }
}

Hope this helps!

//Erik



>


Sponsored Links


Other Threads

1. OpenGL ES works fine on Emulator but on HTC Hero 1.5 it does not render vertices

I had a problem with Ortho on my phone vs on the emulator at one point
as well.  Could you post more of your GL initialization code?  My
problem was something dumb like I was calling orthox using actual
screen dimensions when I needed to either use fixed point there or use
orthof.




-- 

2. JSONObject text must begin with '{' at character 1



Well, "A" characters with a bit of diacritical on top and a seemingly 
random character after it is petty typical for incorrect use of UTF-8 in 
my experience.

I'd suggest that you start by removing the UTF parameters and see what 
happens. I use UTF-8 characters in JSON calls for one of my apps and for 
me it works perfectly by just encoding the query with UTF-8. However, in 
my case I explained very carefully what I wanted from the server people 
- you may not have that advantage... Still, if you capture the stream 
content you should be able to massage it into shape with some effort.

My JSON lookup handler takes a sanity peek at the first character that 
is returned from the call - if it is neither '[' nor '{' I consider it a 
failure.

                Good luck / Jonas

PS. Yes, the app in question is Prisjakt that won the Swedish Android 
Developer Competition '09. Now ,if only the prizes had been of the same 
magnitude as in ADC1/2... ;-)

-- 

3. Archos/Android development

4. JSONObject text must begin with '{' at character 1

5. Orientation change of gsm re-initializes the application

6. Orientation change of gsm re-initializes the application

7. Orientation change of gsm re-initializes the application