Is it possible to focus and blur the Android application by script in the unit?

For some applications on Android and other cell phones, I need to make the application focused and out of focus.
Is it possible to do it by unit script? If the answer is yes, how can I do it?