The real time audio APIs are in native code and they can request for priority use when on foreground.
Samsung used to support real time audio on their S models since many years.
https://developer.samsung.com/galaxy/professional-audio
Which they are now deprecating as they also contributed to the design of AAudio.
People rightfully pointed out that tablets are plenty powerful to do DSP type applications, but something is consuming all the resources. I'm just saying what that something is.
I lost count the amount of times I have fixed junior code doing what should be background stuff written on the main thread, for loops instead of System.arraycopy, allocating memory in loops and lots of other stuff due to lack of proper teaching.
As for Android, the real time audio stack is fully native and Google had to learn from Samsung how to do it properly.