Take a look at this answer, making sure to note the comment below the actual answer. You need to request all the module handles on the device, and then for each, check to see if they're running.
Also, see this BlackBerry forum response, with the content quoted here, because it's a non-SO site:
- Get all module handles (perhaps w/o siblings)
- Traverse through the handle list and filter out library types (leaves us CLDC/Midlet)
- Get app descriptors (main) and associated PID
- If PID exists, implicit conclusion that process is running (may be visible or invisible hidden background process w/o UI).
Another related API would be ApplicationManager.getVisibleApplications(), which allows you to list running apps, that are visible (not background services).
As for which are in the background, you will get the process IDs from above, and then you can check those against the current foreground process ID (only one can be in the foreground ... all the others are in the background). Get the foreground process ID from ApplicationManager.getForegroundProcessId()