Close all background apps except my app

0

I'm thinking of an application that aims to close all other applications that are running in the background, but leave only my application running. Anyone have any idea how to do this?

    
asked by anonymous 12.06.2016 / 17:44

2 answers

4

First I think it would be interesting to explain a bit how the Android architecture works.

Applications developed for Android are written in Java, which means they will be compiled and run within the JVM on the system. In practice, this means that every application runs within a Sandbox, that is, it has no access to other applications or system resources. To use system resources, you must declare this intention and if the user wishes the system releases a port to access this feature.

In case you can not interact directly with an application, what you can do is declare "Intentions" and if the other application behaves, you will execute this "Intention", otherwise the only other interaction is to effectively transfer the user to another APP. In these two possibilities you can control the life cycle of your Intent, and you can finish it whenever you want.

Now for applications that have not been released by you, they will be in another Sandbox and will not interface with your Application, so their life cycle will be controlled by Android, which manages when an application is hidden or completely destroyed according to the need of the system.

So I think the only way to close all other applications is by roaming the phone and running a Linux command from your application, and even then, you run a huge risk of breaking the system.

If your application will consume many features, Android will automatically close other applications to direct the features to the application the user is interacting with.

I hope I have helped.

    
12.06.2016 / 17:59
0

In fact you can do this, there are even several applications that do this. Unfortunately I do not know how it works to help you, I just correct the colleague above.

    
13.06.2016 / 21:27