Record an error encountered in daily development: java. Lang. SecurityException: permission denial: startforeground from PID = 2345, uid = 10395 requires Android. Permission. Foreground_ SERVICE.
This error mainly appears on Android 9.0 phones, because Android 10 has no coverage
Solutions
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
The above error is due to Android 9.0’s new restrictions on permissions. This foreground service permission needs to be statically applied in the androidmanifest.XML
file. Adding the above permission code will not report an error