Example usage for android.app ActivityManager getRunningServices

List of usage examples for android.app ActivityManager getRunningServices

Introduction

In this page you can find the example usage for android.app ActivityManager getRunningServices.

Prototype

@Deprecated
public List<RunningServiceInfo> getRunningServices(int maxNum) throws SecurityException 

Source Link

Document

Return a list of the services that are currently running.

Usage

From source file:com.housekeeper.ar.healthhousekeeper.personalinfo.ModifyInfoActivity.java

public boolean isWorked() {
    ActivityManager myManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ArrayList<ActivityManager.RunningServiceInfo> runningService = (ArrayList<ActivityManager.RunningServiceInfo>) myManager
            .getRunningServices(30);/*ww  w.ja v a 2 s. com*/
    for (int i = 0; i < runningService.size(); i++) {
        Log.i(TAG, "service name:  " + runningService.get(i).service.getClassName().toString());
        if (runningService.get(i).service.getClassName().toString()
                .equals("com.cn.ar.doctorclient.service.CheckUserService")) {
            Log.i(TAG, "check service is running");
            return true;
        }
    }
    Log.i(TAG, "check service is not running");
    return false;
}

From source file:cw.kop.autobackground.sources.SourceListFragment.java

private boolean isServiceRunning(final String className) {
    final ActivityManager manager = (ActivityManager) appContext.getSystemService(Context.ACTIVITY_SERVICE);
    for (final ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (className.equals(service.service.getClassName())) {
            return true;
        }//from  ww  w  . j a  va2 s.  c o  m
    }
    return false;
}

From source file:info.zamojski.soft.towercollector.MainActivity.java

private boolean isServiceRunning(String serviceClassName) {
    ActivityManager activityManager = (ActivityManager) getApplication()
            .getSystemService(Context.ACTIVITY_SERVICE);
    List<RunningServiceInfo> services = activityManager.getRunningServices(Integer.MAX_VALUE);
    for (RunningServiceInfo runningServiceInfo : services) {
        if (runningServiceInfo.service.getClassName().equals(serviceClassName)) {
            return true;
        }/*  ww w  .  j  av a2  s.  c o  m*/
    }
    return false;
}

From source file:me.trashout.fragment.DashboardFragment.java

private boolean isTrashHunterServiceRunning() {
    ActivityManager manager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (TrashHunterService.class.getName().equals(service.service.getClassName())) {
            return true;
        }//  ww  w  .  ja v  a 2s.com
    }
    return false;
}

From source file:org.torproject.android.OrbotMainActivity.java

private boolean isTorServiceRunning() {
    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (TorService.class.getName().equals(service.service.getClassName())) {
            return true;
        }/*from  w w w .  j av  a 2s.  co m*/
    }
    return false;
}

From source file:pro.dbro.bart.TheActivity.java

private boolean usherServiceIsRunning() {
    ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if ("pro.dbro.bart.UsherService".equals(service.service.getClassName())) {
            return true;
        }// ww  w . j a v  a  2s.c o  m
    }
    return false;
}

From source file:com.teeptrak.controller.MainActivity.java

private boolean isDfuServiceRunning() {
    ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (DfuService.class.getName().equals(service.service.getClassName())) {
            return true;
        }/*www. ja va 2 s  . co m*/
    }
    return false;
}

From source file:com.miz.functions.MizLib.java

public static boolean isMovieLibraryBeingUpdated(Context c) {
    ActivityManager manager = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE);
    List<RunningServiceInfo> services = manager.getRunningServices(Integer.MAX_VALUE);
    int count = services.size();
    for (int i = 0; i < count; i++) {
        if (MovieLibraryUpdate.class.getName().equals(services.get(i).service.getClassName())) {
            return true;
        }/*from  w w  w .java  2s .  co m*/
    }
    return false;
}

From source file:com.miz.functions.MizLib.java

public static boolean isTvShowLibraryBeingUpdated(Context c) {
    ActivityManager manager = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE);
    List<RunningServiceInfo> services = manager.getRunningServices(Integer.MAX_VALUE);
    int count = services.size();
    for (int i = 0; i < count; i++) {
        if (TvShowsLibraryUpdate.class.getName().equals(services.get(i).service.getClassName())) {
            return true;
        }/*from w w  w .  j a v a  2s.  c om*/
    }
    return false;
}

From source file:com.miz.functions.MizLib.java

public static boolean isLocalCopyBeingDownloaded(Context c) {
    ActivityManager manager = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE);
    List<RunningServiceInfo> services = manager.getRunningServices(Integer.MAX_VALUE);
    int count = services.size();
    for (int i = 0; i < count; i++) {
        if (MakeAvailableOffline.class.getName().equals(services.get(i).service.getClassName())) {
            return true;
        }/*ww w . jav a 2  s.c om*/
    }
    return false;
}