8

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

Usman Rana
  • 2,067
  • 1
  • 21
  • 32
  • how to get current running applications on Android 6.0?? – hungtdo Jul 20 '17 at 16:30
  • This would be helpful: http://www.programcreek.com/java-api-examples/index.php?api=android.app.usage.UsageStatsManager – Usman Rana Jul 20 '17 at 16:48
  • Thanks! And i think i found a solution for android 7+: https://stackoverflow.com/a/16691633/938427 – hungtdo Jul 21 '17 at 16:03
  • Updated: https://stackoverflow.com/questions/41104739/running-adb-comands-within-app-gives-permission-denied No Ways on android 7 :( (Don't run commands using Process: java.io.IOException: Cannot run program "adb shell ps | grep": error=13, Permission denied) – hungtdo Jul 21 '17 at 16:30

1 Answers1

7

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

Ryan
  • 1,863
  • 13
  • 20
  • thanks for response. can you add any reference for AppUsageManager to achieve this task? – Usman Rana Jan 20 '17 at 17:42
  • Sorry got the name slightly wrong it's https://developer.android.com/reference/android/app/usage/UsageStatsManager.html – Ryan Jan 21 '17 at 15:46
  • 3
    Follwed this: http://www.programcreek.com/java-api-examples/index.php?api=android.app.usage.UsageStatsManager . and it worked for me – Usman Rana Jan 23 '17 at 07:34
  • this isn't true. this app works perfectly on Nougat https://play.google.com/store/apps/details?id=mobi.infolife.taskmanager – deviant Jun 16 '17 at 21:45
  • @deviant you wrong. I tried open a game (no services in game). This app doesn't work truly. – hungtdo Jul 20 '17 at 16:25
  • As @Usman Rana said, his solution is still working on android 8.0. – Lorenzo Von Matterhorn Nov 07 '17 at 06:12
  • I tested the task manager app mentioned by @deviant and as he said it is working on OS 7 but it fails to detect processes on OS8 – A.Alqadomi Nov 21 '17 at 09:30
  • Wow, these restrictions are terrible. – neverMind9 Mar 26 '18 at 10:48
  • 1
    @Ryan there are apps like AppLocker and GalleryLocker that can detect a running app even in android 7.0 , you can find them in playstore,that means its surely possible through UsageStatManager but the question is how – Ravikant Tiwari Aug 10 '18 at 07:23