Page 1 of 1

Detect when apps are manually removed from memory

Posted: 25 Mar 2019 23:48
by ariloc
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.

Re: Detect when apps are manually removed from memory

Posted: 26 Mar 2019 06:29
by Desmanto
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.