Some of the Android devices have background limitations while the screen is locked or you are playing music in the background. To fix this issue, check the below solutions to adjust your phone settings:
Solution 1
Device Settings > Advanced Settings > Battery manager > Power plan set to Performance
Solution 2
Device Settings > Advanced Settings > Battery Manager > Protected apps – check your app as Protected
Solution 3
Enable Device Settings > Apps > your app > Battery > Power-intensive prompt and Keep running after screen off