0

Programmatically, how do I:

a) Find all the processess running on my Blackberry?

b) Which of those processes are running in the background?

Is there an api or documentation I can look at, or maybe get a coded example?

Thanks in advance for any help

2 Answers2

2

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:


  1. Get all module handles (perhaps w/o siblings)
  2. Traverse through the handle list and filter out library types (leaves us CLDC/Midlet)
  3. Get app descriptors (main) and associated PID
  4. 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()

Community
  • 1
  • 1
Nate
  • 30,589
  • 12
  • 76
  • 201
  • Thanks for the response and help. int[] getModules = CodeModuleManager.getModuleHandles(); gives me numbers such as [l@f91e18c8 and [f4@34fgj7 and so forth. How Can I get a print out the actual names of the apps such as 'Messages', 'phone', 'facebook' ect – BirthOfTragedy Sep 25 '12 at 10:16
  • @BirthOfTragedy, Once you have the module handle (which is not a name, just a reference to a module), then you could probably use [other methods in CodeModuleManager](http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/system/CodeModuleManager.html#getModuleAliasName%28int,%20int%29), or try something like [ApplicationDescriptor.getName()](http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/system/ApplicationDescriptor.html#getName()), with an [example on SO here](http://stackoverflow.com/a/11843571/119114) – Nate Sep 25 '12 at 20:52
1
This code will help you to find out current running applications

ApplicationManager appMan = ApplicationManager.getApplicationManager();
        ApplicationDescriptor appDes[] = appMan.getVisibleApplications();

        for (int i = 0; i < appDes.length; i++) 
        {
                  result = appDes[i].getModuleName();
          System.Out.Println("Currently Running application " +result ) 
        }
AK Joshi
  • 877
  • 6
  • 20