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. Brightness Android 2.2 vs Android 2.1

I've just realised Android 2.2 has less brightness (max level) than
Android 2.1.
It's looks like less AMOLED :(

In Setting > Display > Brightness is on top.

Any reason? save battery?

Cheers

-- 

2. OOT : Thanks to Bos Nurfat

Barang sdh nyampe td pagi, test dan ajib bos.
Recomended seller neh bos nurfat, cepet bgt dan kaga pake lama.
Hehehehe...

*sorry om momod ganggu bandwidthnya*









Forza Internazionale Milano
Sent from my  9700 / 5.0.0.656
re...@ratjoen.com

-- 
"Indonesian Android Community [id-android]" 

3. can i re-install an app without shutting down the emulator?

4. OOT: iseng2 weekend

5. isi sms forward sebagai email

6. Ecodazoo

7. How to compile libfuse for android?