0

I am building an app which runs in the background and I want to display a short text but only when for example the user is checking images on Instagram. So I need to check if Instagram is in use and then put the message in some kind of if statement.

How do I check if a specific app is currently used in the foreground? I searched around but can only find old posts with codes that are not supported anymore.

I am new to building apps so can someone please explain me how to accomplish this?

user4958875
  • 53
  • 1
  • 9
  • 1
    check this ans https://stackoverflow.com/questions/37844923/how-to-check-if-an-external-app-is-running-on-foreground – AskNilesh Sep 19 '17 at 11:09
  • Fortunately, this should not be possible on newer versions of Android, for privacy and security reasons. – CommonsWare Sep 19 '17 at 11:09
  • @NileshRathod I already checked the anwer but someone states getRunningAppProcesses is not used anymore so I can't use it. – user4958875 Sep 19 '17 at 11:11

0 Answers0