프로그램/Android

안드로이드 실행중인 서비스 체크[Android Service Running Check]

잡식성초보 2017. 9. 6. 14:52

안드로이드 Service가 실행중인지 체크하는 함수입니다.




public Boolean isLaunchingService(Context mContext){

    ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);

    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (서비스명.class.getName().equals(service.service.getClassName())) {
            return true;
        }
    }

    return  false;
}
반응형