On closing game and opening another app

If a player pauses a game and opens another app, is it possible to know which app it was, when I reopen the game?

Generally not.

I’m pretty sure that type of information is disallowed from the OS. I mean, that’s a pretty bold invasion of privacy, isn’t it? Why would your app need to know what other app the user was just using?

1 Like

If your application has the correct permissions with the OS it can use the APIs provided by the OS to list all currently active processes. On Windows, for example, you would use EnumProcesses which is part of kernel32.dll.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682623(v=vs.85).aspx

On macOS, you would use NSWorkspace.

https://developer.apple.com/documentation/appkit/nsworkspace

On Linux, you would simply check the contents of the /proc folder.

https://en.wikipedia.org/wiki/Procfs

On Android, you would use ActivityManager.

https://developer.android.com/reference/android/app/ActivityManager.html

1 Like