포그라운드 서비스 중지
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
포그라운드 서비스가 포그라운드에서 실행되는 것을 중지하려면 두 가지 옵션이 있습니다. 서비스를 중지하거나 서비스를 실행 상태로 유지하되 포그라운드에서 삭제할 수 있습니다.
서비스를 중지하는 것과 동일한 방식으로 포그라운드 서비스를 중지할 수 있습니다. 서비스가 자체 stopSelf()
메서드를 호출하거나 다른 구성요소가 stopService()
를 호출하여 서비스를 중지할 수 있습니다. 포그라운드에서 실행되는 동안 서비스를 중지하면 알림이 삭제됩니다.
포그라운드에서 서비스를 삭제하려면 서비스 내부에서 stopForeground(int)
를 호출합니다. 이 메서드는 상태 표시줄 알림도 삭제할지 여부를 나타내는 불리언을 사용합니다. 서비스는 계속 실행되지만 더 이상 포그라운드 서비스가 아닙니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-27(UTC)"],[],[],null,["If you want a foreground service to stop running in the foreground, you have\ntwo options. You can stop the service, or you can leave the service\nrunning but remove it from the foreground.\n\nYou can stop a foreground service\n[the same way you would stop any service](/develop/background-work/services#Stopping). The service can\ncall its own [`stopSelf()`](/reference/android/app/Service#stopSelf()) method, or another component can stop it\nby calling [`stopService()`](/reference/android/content/Context#stopService(android.content.Intent)). If you stop the service while it runs\nin the foreground, its notification is removed.\n\nTo remove a service from the foreground, call\n[`stopForeground(int)`](/reference/android/app/Service#stopForeground(int))\nfrom inside the service. This method takes a boolean, which indicates whether to\nremove the status bar notification as well. The service continues to run, but\nit is no longer a foreground service."]]