Android how to check if the intent service is still running or has stopped running

StackOverflow https://stackoverflow.com/questions/7440473

  •  20-01-2021
  •  | 
  •  

문제

I need to know if all intentservices in the queue are "consumed" or the other way is to find out if it is still doing something so that I don't continue until all services have stopped running. Any ideas?

도움이 되었습니까?

해결책

Try this may be useful for u

private boolean isMyServiceRunning() {
    ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if ("com.example.MyService".equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top