0

I just would like to know if it is possible, in any way, to know from my app that another app has been opened and if yes. Can I retrieve the name of the app.

I think that it's impossible, but maybe it exists a tricky way to do it.

Thanks

kschaeffler
  • 3,663
  • 7
  • 29
  • 41

2 Answers2

1

Sorry, but no, there's no way to do this. You actually can get the other pids on the system via standard POSIX calls, but when you're in the background, you're not actually running, so you can't do anything.

Lily Ballard
  • 169,315
  • 25
  • 364
  • 333
1

Well, you can get a list of currently running processes using sysctl

see this qn:

Get Free Mem and Running Processes

However, since your process can explicitly run in the background for 10 minutes after being backgrounded (unless you're running voip, audio, or location service), the utility of this may be limited. You will also need to find a way to determine if a process is running in the foreground (perhaps checking for the delta of running processes?)

Community
  • 1
  • 1
futureelite7
  • 11,227
  • 9
  • 51
  • 85