• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to learn which app is running, and kill some of them?

Hi, i am looking for a way to create an app which will run on the background, and when i press both volume down and volume up button it will kill all the app that currently running (some of them).

I nailed the event click both volume button and background service but i dont know how i can kill another app thats not from my app's activity.

I would prefer non-rooting required but if its not possible, rooting is fine since the purpose of this project is mainly education.

Thank you for reading.

Edit: I am not looking for a block of code, just some keywords or solutions. Sure some code example would be nice.
 
Tap on the square box on the right and close all or individual apps.
HTH
So what you mean is that i create something like a macro which will click on the square box and close everything?

If thats what you mean, could you please provide me some more information on how i can simulate touch on screen please?
I was also tried to follow that appoarch but then stuck at how to simulate touch on screen.

Thank you for your help
 
Check out Macrodroid. Very easy to create a macro that will accomplish what you're looking for. The macro itself can be structured to run at specified time intervals and/or to create a Widget/button on your home screen that would execute every time you tap on it.
Personally, I would go with dontpanicbobby's suggestion, unless the automation process appeals to you.

I checked that app out and in my opinion that app is highly overrated (No pixel reader). Anyway, this project is for education purpose which mean that i want to learn how to do it rather than get it done by using existing application.

Thank you for your help
 
So your first issue is to programmatically get a list of running apps on the device. Some info here

https://stackoverflow.com/questions/3304685/how-to-get-the-list-of-running-applications

Now how you kill an app (assuming you have permission) is another issue. If you could get process ID (PID) of the app, you could exec the kill command

Code:
int processID = // Somehow get the PID of the app
Runtime runtime = Runtime.getRuntime();
runtime.exec(new String[] { "/bin/bash kill " + processID});

P.S. This code is completely untried, it's just off the top of my head to give you some ideas.
 
So your first issue is to programmatically get a list of running apps on the device. Some info here

https://stackoverflow.com/questions/3304685/how-to-get-the-list-of-running-applications

Now how you kill an app (assuming you have permission) is another issue. If you could get process ID (PID) of the app, you could exec the kill command

Code:
int processID = // Somehow get the PID of the app
Runtime runtime = Runtime.getRuntime();
runtime.exec(new String[] { "/bin/bash kill " + processID});

P.S. This code is completely untried, it's just off the top of my head to give you some ideas.

Say, if my device is rooted i should have permission right?

That command that you run, does it required a pc connected to work?
 
Say, if my device is rooted i should have permission right?

That command that you run, does it required a pc connected to work?

No. kill is a standard command on Unix systems. Whether it's there on Android I can't say for sure. You'll have to do some investigation.
What you could do is fire up an adb session to your device and see if it's there. If you can issue the kill command at the prompt, then it should work programmatically from your app too.
 
Back
Top Bottom