Android- programmatically restrict which apps can be run

2k views Asked by At

I'm building an app that needs to restrict which apps can be run along with it.

In example, when my app is running (foreground or background) I can allow user to run only GoogleMaps, and MusicPlayer.

I've read a bit about Device Policy Controller 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?

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.

Is there any way of handling this problem programmatically?

1

There are 1 answers

2
macros013 On BEST ANSWER

I don't think that Device Policy Controller is a right thing for you. And you can't just kill other apps without root.

So some kind of user-friendly way to achieve the goal is to check running apps list with ActivityManager.getRunningAppProcesses and to notify user that he has to finish particular apps to use your app.