Created
October 6, 2014 02:37
-
-
Save easternHong/df35eff2100afcd3eff3 to your computer and use it in GitHub Desktop.
checkService running or not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 判断服务是否启动 | |
* | |
* @param className | |
* @return | |
*/ | |
private boolean checkServiceRunning(String className) { | |
boolean isRunning = false; | |
ActivityManager am = (ActivityManager) this | |
.getSystemService(Context.ACTIVITY_SERVICE); | |
List<ActivityManager.RunningServiceInfo> amRun = am | |
.getRunningServices(30); | |
if (amRun.size() < 1) | |
return false; | |
for (int i = 0; i < amRun.size(); i++) | |
if (amRun.get(i).service.getClassName().equals(className)) { | |
isRunning = true; | |
break; | |
} | |
return isRunning; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment