title: Android- programmatically restrict which apps can be run
body: <p>I'm building an app that needs to restrict which apps can be run along with it. </p>
  
  <p>In example, when my app is running (foreground or background) I can allow user  to run only GoogleMaps, and MusicPlayer.</p>
  
  <p>I've read a bit about <a href="https://developers.google.com/android/work/build-dpc" rel="nofollow noreferrer"><code>Device Policy Controller</code></a> and creating profiles, and up to some point it seems to have the feature I need, but it is designed for enterprise deployment, and user needs to encrypt their phone beforehand. Is creating personalized profiles a way to go?</p>
  
  <p>My other idea was to run a service that each few milliseconds check if there is any forbidden app running and finish it, but it seems to be not robust.</p>
  
  <p>Is there any way of handling this problem programmatically?</p>