Detect when apps are manually removed from memory

Post your questions and help other users.

Moderator: Martin

Post Reply
ariloc
Posts: 109
Joined: 05 Jun 2016 21:36

Detect when apps are manually removed from memory

Post by ariloc » 25 Mar 2019 23:48

Hi, posting here again, as I couldn't find the answer to this searching around in the forum. As I mentioned in the previous topic I made, I recently upgraded from Android 8 to 9. In the previous version, I found out that everytime I removed an app from the multitask, an Announcement was made by the system, which could be detected by trigger UI Event, and due to its straight forward format ("[app_name] dismissed"), I could exactly know which app was removed. This served for me the purpose to know when certain apps I opened before that required to disable root access, were no longer running in the background, and so allowed to, after closing them, enabling root access again.

Now in Android 9, that announcement is no longer made or it's just empty, and other UI Events don't help either. So I guess I had to look for another and maybe better method. I read that I could use a root command to check if an app process is running, so I could run that whenever I swiped away an app, and so know if that app was the one I wanted. But as I said, by that moment Automagic wouldn't be able to run any root related actions, so I'm stuck and maybe hope you can help me.

As always, thanks.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Detect when apps are manually removed from memory

Post by Desmanto » 26 Mar 2019 06:29

I just knew that swiping recent create UI event. I tried it in RR 7.0.1 pie, with oreo recent style, it still give the announcement. If your ROM support oreo recent style, you can try to change to that. Other method is to freeze the default launcher and use other launcher that has oreo recent style, such as nova.

You can check the app is running foreground using App Task Started/Ended. But you can't use it with the background app. It requires continuous probing to the dumpsys to check for recent app.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply