How can I lock other Apps?

I'm trying to make an app like AppLock but I have no clue how I can affect other apps. Can someone try to explain me, or send me a link to a tutorial, how I could make a lockscreen if the user wants to open an app? My thanks!