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. Speed difference between DOM and SAX parser for small documents

Hi,

currently, we use the SAX parser bundled with Android to parse XML
coming from our servers. We found however that parsing the XML using a
SAX handler is prone to errors and difficult to maintain. Therefore I
thought about switiching to a DOM parser, and probably also a wrapper
around it (like JDOM) for convenience.

But, does anyone know how big the performance impact will be? Is it
negligible for documents that are merely 10-50k in size? I remember
that in early alphas of Android, the DOM parser was noticeably slower,
but I also heard that this has become better meanwhile.

Thanks,
Matthias
--~--~---------~--~----~------------~-------~--~----~

2. Problem when updating ListView

Hi all,

I have a ListView with a footer View that is bind to a custom
ArrayAdapter within a ListActivity. When creating the activity, I fill
in the ArrayAdapter with some items through a dedicated thread. At the
end, the thread calls setListAdapter and requestFocus through a
handler. At this point, everything works fine. I mean, when scrolling
the ListView, all items get hilighted correctly, even when the footer
view gets focused. Now, I need to update the items in the ListView by
adding a few items more. Again, I use a thread to update the
ArrayAdapter and use a handler to post invalidate() on the ListView.
Now, when I scroll down the ListView and reach the footer view, the
last item of the list gets unreadable when losing focus. The same
happens with the first item of the list when reaching a header view or
a parent tab. I tried requestFocus() again but it didn't work. I also
tried android:drawSelectorOnTop="false" with no more result.

Any guess? Help is welcomed.

Thanks.
--~--~---------~--~----~------------~-------~--~----~

3. iPhone Flops in India

4. How to update the SDK

5. ContentProvider instance

6. Building a .so lib

7. emulator support in 2.6.27 ?