use of android.app.ActivityManager.RunningServiceInfo in project JustAndroid by chinaltz.
the class AbAppUtil method isServiceRunning.
/**
* 用来判断服务是否运行.
*
* @param context the context
* @param className 判断的服务名字 "com.xxx.xx..XXXService"
* @return true 在运行 false 不在运行
*/
public static boolean isServiceRunning(Context context, String className) {
boolean isRunning = false;
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningServiceInfo> servicesList = activityManager.getRunningServices(Integer.MAX_VALUE);
Iterator<RunningServiceInfo> l = servicesList.iterator();
while (l.hasNext()) {
RunningServiceInfo si = (RunningServiceInfo) l.next();
if (className.equals(si.service.getClassName())) {
isRunning = true;
}
}
return isRunning;
}
use of android.app.ActivityManager.RunningServiceInfo in project superCleanMaster by joyoyao.
the class AppUtil method isServiceRunning.
/**
* 用来判断服务是否运行.
*
* @param context the context
* @param className 判断的服务名字 "com.xxx.xx..XXXService"
* @return true 在运行 false 不在运行
*/
public static boolean isServiceRunning(Context context, String className) {
boolean isRunning = false;
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningServiceInfo> servicesList = activityManager.getRunningServices(Integer.MAX_VALUE);
Iterator<RunningServiceInfo> l = servicesList.iterator();
while (l.hasNext()) {
RunningServiceInfo si = (RunningServiceInfo) l.next();
if (className.equals(si.service.getClassName())) {
isRunning = true;
}
}
return isRunning;
}
use of android.app.ActivityManager.RunningServiceInfo in project mobile-android by photo.
the class UploaderServiceUtils method isServiceRunning.
/**
* Check whether UploaderService is already running
*
* @return
*/
public static boolean isServiceRunning(Class<? extends AbstractUploaderService> uploaderServiceClass) {
final ActivityManager activityManager = (ActivityManager) CommonConfigurationUtils.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
final List<RunningServiceInfo> services = activityManager.getRunningServices(Integer.MAX_VALUE);
String serviceClassName = uploaderServiceClass.getName();
for (RunningServiceInfo runningServiceInfo : services) {
if (runningServiceInfo.service.getClassName().equals(serviceClassName)) {
return true;
}
}
return false;
}
use of android.app.ActivityManager.RunningServiceInfo in project AprilBeacon-Android-SDK by AprilBrother.
the class ServiceStatusUtils method isServiceRunning.
public static boolean isServiceRunning(Context context, String serviename) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningServiceInfo> infos = am.getRunningServices(100);
for (RunningServiceInfo info : infos) {
String classname = info.service.getClassName();
if (serviename.equals(classname)) {
return true;
}
}
return false;
}
use of android.app.ActivityManager.RunningServiceInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ProcessStatsDetail method updateRunningServices.
private void updateRunningServices() {
ActivityManager activityManager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
List<RunningServiceInfo> runningServices = activityManager.getRunningServices(Integer.MAX_VALUE);
// Set all services as not running, then turn back on the ones we find.
int N = mServiceMap.size();
for (int i = 0; i < N; i++) {
mServiceMap.valueAt(i).setCancellable(false);
}
N = runningServices.size();
for (int i = 0; i < N; i++) {
RunningServiceInfo runningService = runningServices.get(i);
if (!runningService.started && runningService.clientLabel == 0) {
continue;
}
if ((runningService.flags & RunningServiceInfo.FLAG_PERSISTENT_PROCESS) != 0) {
continue;
}
final ComponentName service = runningService.service;
CancellablePreference pref = mServiceMap.get(service);
if (pref != null) {
pref.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(CancellablePreference preference) {
stopService(service.getPackageName(), service.getClassName());
}
});
pref.setCancellable(true);
}
}
}
Aggregations