Back to project page DistributedMemory.
The source code is released under:
Apache License
If you think the Android project DistributedMemory listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.faudroids.distributedmemory.utils; //w w w . ja v a 2 s . c o m import android.app.ActivityManager; import android.content.Context; import javax.inject.Inject; import javax.inject.Singleton; @Singleton public class ServiceUtils { private final Context context; @Inject public ServiceUtils(Context context) { this.context = context; } public boolean isServiceRunning(Class<?> serviceClass) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClass.getName().equals(service.service.getClassName())) { return true; } } return false; } }