Check if app is in recent apps

pheonixforcrd

New member
Hi
I want to make a shortcut to perform 2 opposite actions depending on whether a certain app is in (recent apps) or not

So i want to check if app is in recent apps
 

sampleuserhere

Active member
Grant the following permission via ADB android.permission.DUMP. After that, run the following shell command with Shell Script action (toggle block next action until complete).

Code:
dumpsys activity recents | tail -n +$(dumpsys activity recents | grep -n "Visible recent tasks" | head -n 1 | cut -d: -f1) | grep "realActivity=" | sed -E "s/^.*\{(.*)\/.*/\1/g" | tr "\n" "," | sed "s/,$//g"

It return the package names separated by comma.

The parsing method may not work though, due to some differences in dump pattern. However the recents details should be available in the dump provided by dumpsys activity recents ( after "Visible recent tasks" line. )
 
Top