How To Allow An App To Always Run In Background In MIUI 12

Follow the steps given below, in order to achieve what you want:
1. Open Settings
2. Choose Apps

3. Click on Manage Apps

4. Choose the desired app

5. Turn AutoStart "ON"

6. Scroll down to Battery Saver, and then click on it

7. Select No Restrictions

Till Now, we have instructed MIUI pretty much, not to kill the app while running in the background but this is not sufficient because of the reason that when you will clear your recent apps or boost your phone to release some RAM, MIUI can still kill your app's background process. So, we need to lock the app so that MIUI can exclude the app while killing other apps when you boost your phone or clear your recent apps. The procedure to Lock apps in background is a bit different from the previous MIUI versions. So, follow the steps ahead and you will be all done.
1. Open Security app from Xiaomi
2. Press the settings icon present on the top right corner of the screen

3. Click on Boost Speed

4. Click on Lock Apps

5. Turn the toggle ON for your desired app

That's it. Now you can clear your app from recent apps and can do other RAM releasing activities, your app will keep on running in background. I hope I have helped you, if you think so, you can put your thoughts in the comment box given below, it will definitely motivate me.