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:it.durip_app.MACActivity.java

private boolean isOlsrRunning() {
    String serviceName = "it.durip_app.Olsr";
    ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceName.equals(service.service.getClassName())) {
            return true;
        }/*from  w  ww.j a  v a2 s  .c  o m*/
    }
    return false;
}

From source file:it.durip_app.MACActivity.java

private boolean isIperfRunning() {
    String serviceName = "it.durip_app.Olsr";
    ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceName.equals(service.service.getClassName())) {
            return true;
        }//  w w w  .  ja  v  a  2s . com
    }
    return false;
}

From source file:com.remdo.app.MainActivity.java

private boolean isGEORunning() {
    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (GeopositioningService.class.getName().equals(service.service.getClassName())) {
            return true;
        }/*from   www . j  a  v  a2 s  .  c  o m*/
    }
    return false;
}

From source file:com.remdo.app.MainActivity.java

private boolean isALERTSRunning() {
    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (NotificationService.class.getName().equals(service.service.getClassName())) {
            return true;
        }/*from   w  ww.  j a  v  a2s.  co m*/
    }
    return false;
}

From source file:fr.s13d.photobackup.preferences.PBPreferenceFragment.java

private boolean isPhotoBackupServiceRunning() {
    final Activity activity = getActivity();
    if (activity != null) {
        final ActivityManager manager = (ActivityManager) getActivity()
                .getSystemService(Context.ACTIVITY_SERVICE);
        for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
            boolean sameClass = PBService.class.getName().equals(service.service.getClassName());
            boolean samePackage = BuildConfig.APPLICATION_ID.equals(service.service.getPackageName());
            if (sameClass && samePackage) {
                Log.i(LOG_TAG, "Service is running");
                return true;
            }/*from w w  w  .  j  a v a  2s.c  o m*/
        }
    }
    Log.i(LOG_TAG, "Service or activity is NOT running");
    return false;
}

From source file:org.exobel.routerkeygen.ui.Preferences.java

private boolean isDictionaryServiceRunning() {
    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if ("org.exobel.routerkeygen.DictionaryDownloadService".equals(service.service.getClassName())) {
            return true;
        }// ww  w .  j a  v  a2  s  .  com
    }
    return false;
}

From source file:uk.org.openseizuredetector.MainActivity.java

/**
 * Based on http://stackoverflow.com/questions/7440473/android-how-to-check-if-the-intent-service-is-still-running-or-has-stopped-running
 *//*from w ww .  java2  s  . c o  m*/
public boolean isServerRunning() {
    //Log.v(TAG,"isServerRunning()................");
    ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        //Log.v(TAG,"Service: "+service.service.getClassName());
        if ("uk.org.openseizuredetector.SdServer".equals(service.service.getClassName())) {
            //Log.v(TAG,"Yes!");
            return true;
        }
    }
    //Log.v(TAG,"No!");
    return false;
}

From source file:edu.rutgers.winlab.crowdpp.ui.HomeFragment.java

private boolean isMyServiceRunning() {
    //final View view = inflater.inflate(R.layout.home_fragment_layout, container, false);   
    ActivityManager manager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if ("edu.rutgers.winlab.crowdpp.service.SpeakerCountService".equals(service.service.getClassName())) {
            return true;

        }//from  w w w  .  j  av  a2 s .c  om
    }
    return false;
}

From source file:devicroft.burnboy.Activities.MainActivity.java

private boolean isServiceRunning(Class<?> serviceClass) {
    //https://stackoverflow.com/questions/600207/how-to-check-if-a-service-is-running-on-android
    ActivityManager manager = (ActivityManager) getSystemService(this.ACTIVITY_SERVICE);
    final List<ActivityManager.RunningServiceInfo> services = manager.getRunningServices(Integer.MAX_VALUE);

    for (ActivityManager.RunningServiceInfo runningServiceInfo : services) {
        if (runningServiceInfo.service.getClassName().equals(serviceClass.getSimpleName())
                || runningServiceInfo.service.getClassName().equals("LogService.java")) {
            return true;
        }//from   w  ww  .j  ava 2  s . c o  m
    }
    return false;
}

From source file:devicroft.burnboy.Activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(LOG_TAG, "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initialiseAd();// w  ww.  java  2 s  .  c o  m
    setupFAB();

    IntentFilter filter = new IntentFilter("devicroft.BurnBoy.CANCEL_NOTIFY");
    this.registerReceiver(new NotificationCancelReceiver(), filter);
    if (getIntent().getAction() == Intent.ACTION_DELETE) {
        Intent intent = new Intent();
        intent.setAction("devicroft.BurnBoy.CANCEL_NOTIFY");
        intent.putExtra("id", NotificationCancelReceiver.NOTIFICATION_ID);
        sendBroadcast(intent);
    }

    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (LogService.getName().equals(service.service.getClassName())) {
            Log.d(LOG_TAG, " REBIND on SERVICE");
            Toast.makeText(this, "Still logging movement", Toast.LENGTH_SHORT);
            this.bindService(new Intent(this, LogService.class), serviceConnection, Context.BIND_AUTO_CREATE);
        }
    }

    TextView distance = (TextView) findViewById(R.id.distanceFocus);
}