Close all applications in the background except my app

Asked

Viewed 970 times

0

I am thinking of an application that aims to close all other applications that are running in the background, however, leave only my application running. Does anyone have any idea how to do that?

2 answers

4


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

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

In case you can’t interact directly with an application, what you can do is declare "Intentions" and if the other application behaves, it 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 (Intention), and you can finish it when you want.

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

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

If your application is consuming too many features, Android will automatically close other applications to direct the features to the application where the user is interacting.

I hope I’ve helped.

  • Lucas then has no way to use an Intent that triggers the android button: (close applications)?

  • 1

    No, for security reasons you can only interact with other applications that you declare and that the user authorizes. The only one that can terminate other application processes is OS. You can only do this if you are rooted

0

In fact, there are many applications that do this. Unfortunately I don’t know how it works to help you, I just correct the colleague above.

  • The applications that "close" the applications usually send a Broadcast of Restart, then as the other applications have not been viewed they take almost nothing of memory, they are in Stand-by, but if you look in the manager you will see that they are still open.

  • Thus, I have seen similar applications that do this, including in technological events. Hence I got this curiosity. If I learn from here to there put here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.