Context.startForegroundService() did not then call Service.startForeground()
android o os 2017. 6. 8. 17:15Target를 "O" 로 했을 때
startService를 사용하면 illegalArgumentException 에러가 나온다.Background Service 에서 사용하기 위해 Android O OS에서 코드를 수정해야 한다.
2일 뻘짓해서 찾아냄.
해결책
1. Service class를 상속 받는다.
2. 상속받은 Service class를 Context.startForegroundService()로 실행
3. Service class를 상속받은 Class 내에 startForeground() 메소드를 사용한다.
가이드라인을 보면
startService 사용 -> startForeground 사용이 Android O OS에서
startForegroundService사용과 같다고 나오는데 왜 startForegroundService만 사용하면
Context.startForegroundService() did not then call Service.startForeground() 에러가 나오는지 모르겠음. startForeground 적용하니 됨.


