Is it possible to root an android phone while a specific application is running? Basically I'm using SafetyNet by Google to check at the beginning whenever my application is opened to see if a phone is rooted. If it is, I'll prevent my app from running. So as you can tell if it is possible to root an android phone while a specific app is running, then what I'm doing can be bypassed. So is it possible?
I hope I understood the question right, you have an app and you wish to detect if the phone is rooted, and if it is, than you stop your app from running?

If that's the case I am not sure. Simply because, what code can you write in your app that checks if your phone is rooted or not? Since the user is the king in that case, and your app is not system app but rather a third party if you will, you have a limited set of permissions you can ask from the user to give you. None of these permissions will help you however to determine if the phone is rooted or not. Hence, as far as I know, not possible. However if you ever stumble across some hack that let's you do it, please let me know :)