I'm trying to create an app ("ShowStack") to view the current App Back Stack (for development purposes). I know it can be done by using adb with the command "adb shell dumpsys activity activities". I tried using ActivityManager functions getAppTasks() and getRunningProcesses, etc. But these only return a list of 1 item, the current app/task "ShowStack", which I already knew thank you.
How can I view all tasks/activities?
There's no API that lets you peek the whole backstack. Unless you are targeting rooted devices, you are most likely out of luck as there's no way to inspect that for security/privacy reasons.