Android Open Source - AndroidText Util






From Project

Back to project page AndroidText.

License

The source code is released under:

Apache License

If you think the Android project AndroidText listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.jiechic.androidtext._1_daemon;
import java.util.List;
/*w  w  w  .  ja  va2 s.co m*/
import android.app.ActivityManager;
import android.content.Context;

/**
 * Created by jiechic on 14-10-15.
 */
public class Util {
    // ?????????????
    public static boolean isServiceAlive(Context context,
                                         Class serviceClassName) {
        ActivityManager manager = (ActivityManager) context
                .getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningServiceInfo> running = manager
                .getRunningServices(Integer.MAX_VALUE);

        if (running == null || running.size() == 0) {
            return false;
        }

        for (int i = 0; i < running.size(); i++) {
            if (running.get(i).service.getClassName().equals(serviceClassName.getName())) {
                return true;
            }
        }
        return false;
    }
}




Java Source Code List

com.jiechic.androidtext.ApplicationTest.java
com.jiechic.androidtext.MainActivity.java
com.jiechic.androidtext._1_daemon.Util.java
com.jiechic.androidtext._1_daemon._1_DaemonActivity.java
com.jiechic.androidtext._1_daemon._1_Service1.java
com.jiechic.androidtext._1_daemon._1_Service2.java
com.jiechic.androidtext.coreActivity.java