3

I am trying to build an application in which a service can check whether an external application is running at foreground or not.

For example, when we enter in Google Chrome, this service automatically detects what package has been executed and reacts in one way or another.

  • It's that even possible?
  • I have heard about 'getRunningTasks' method but is deprecated on new Android versions

Any suggestion is appreciated.

Carlos
  • 57
  • 1
  • 6
  • Possible duplicate of [How to check current running applications in Android?](http://stackoverflow.com/questions/3278895/how-to-check-current-running-applications-in-android) – NoChinDeluxe Jun 15 '16 at 20:43
  • @NoChinDeluxe How can it be a duplicate if he's remarking that the method used in that answer you post is no longer valid? By the way, he needs to check the foreground app not just background processes. – Nacho Ramos Sánchez Jun 15 '16 at 20:54
  • @NachoRamosSánchez - There are several answers on that question, including up-to-date, usable information. – NoChinDeluxe Jun 15 '16 at 21:02
  • @NoChinDeluxe Sorry if I don't see that. There are 3 answers, two of them deprecated and one useless. This is what he's talking about http://stackoverflow.com/questions/30619349/android-5-1-1-and-above-getrunningappprocesses-returns-my-application-packag – Nacho Ramos Sánchez Jun 15 '16 at 21:10
  • @NachoRamosSánchez - This answer is correct: http://stackoverflow.com/a/5801755/3962091 -- The method used in that answer is not deprecated and it works completely fine. It will give you the package name of the app that is currently in the foreground, which is exactly the info this question is seeking. – NoChinDeluxe Jun 15 '16 at 21:19
  • @NoChinDeluxe Android 5.1.1 and above (6.0 Marshmallow) killed getRunningAppProcesses() as well. – Nacho Ramos Sánchez Jun 15 '16 at 21:22

0 Answers0