当我从告诉我startService(...)
的{{1}}内部调用Activity.onStart()
时,我遇到了崩溃。
这对我来说似乎没有意义,因为该应用程序必须放在Not allowed to start service app is in background
中。 Documentation here also clearly says an application is considered in the foreground when an activity is started, and has no restrictions on service creation.
Activity.onStart()
不知道为什么将此问题标记为重复问题。 It turns out it is a known issue on Android P.感谢Carmen Alvarez帮助我找到正确的答案。