I am using Service
Class on the Android O OS.
I plan to use the Service
in the background.
The Android documentation states that
If your app targets API level 26 or higher, the system imposes restrictions on using or creating background services unless the app itself is in the foreground. If an app needs to create a foreground service, the app should call startForegroundService()
.
If you use startForegroundService()
, the Service
throws the following error.
Context.startForegroundService() did not then call
Service.startForeground()
What's wrong with this?
question from:
https://stackoverflow.com/questions/66051322/i-have-a-major-crash-on-android-11 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…