Detect current running application in Android Nougat 7.+ version

Usman Rana picture Usman Rana · Jan 20, 2017 · Viewed 7.6k times · Source

Android team changed their approaches to get current running applications from time to time. I am able to get current running applications upto Marshmallow 6.0 version but i want to ask that how can i get these in Nougat 7.0 version? Is there anyway to do that? Please guide towards solutions. I have searched a lot but could find any appropriate way to that.

Thanks

Answer

Ryan picture Ryan · Jan 20, 2017

Simple answer: no, you can't.

Long answer: you can't get the running process but you can retrospectively see what was running through the UsageStatsManager (with the appropriate permissions, of course). The reason you can't get the running process is that Android have locked down the permissions of /proc