Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 34
Registered: ‎07-25-2008
My Device: Not Specified
Accepted Solution

Determining if application is running



I am developing an application that has a background thread which invokes a UIApplication. 

Is there anyway i can determine from this backgroud thread whether the UIApplication is already running? 

I tried to use Application.isAlive or isForeground, but i dont have the instance of this UIApplication in the backround thread.


In short, can anyone suggest how to determine if application is running from outside the application? (excuse the ill-framed sentence Smiley Tongue )


Thanks in advance


Posts: 213
Registered: ‎07-18-2008
My Device: Not Specified

Re: Determining if application is running

why dont you use runtime store to do this. take a look at this BB article which does something similar.







problemSolved() ? kudosPlease():kudosPlease();
Posts: 36
Registered: ‎07-14-2008
My Device: Not Specified

Re: Determining if application is running

You can use the getVisibleApplications method in the net.rim.device.api.system.ApplicationManager class to retrieve descriptors for visible, running applications.


I think if you explain why you are looking for this function, we may be able to suggest a better solution instead.



Posts: 191
Registered: ‎04-03-2008
My Device: Bold 9700

Re: Determining if application is running

  Hey Shraddha, how's it going?  Smiley Happy


  In addition to the afore-mentioned methods, here's how I do what you're looking for.  It's a little old, and there's certainly room for improvement, but it's worked for me in the past.  "NoSuchModuleException" is one of my own, it's not part of RIM's API - basically just a marker on top of Exception.



public class ProcessUtils { public static int getProcessId(String moduleName) throws NoSuchModuleException { ApplicationManager appMgr = ApplicationManager.getApplicationManager(); int moduleHandle = CodeModuleManager.getModuleHandle(moduleName); if (moduleHandle == 0) { throw new NoSuchModuleException(); } ApplicationDescriptor[] appDes = CodeModuleManager.getApplicationDescriptors(moduleHandle); return appMgr.getProcessId(appDes[0]); } public static boolean isServiceRunning(String moduleName) { try { if (getProcessId(moduleName) == -1) { return false; } else { return true; } } catch (NoSuchModuleException e) { // This could be a problem... return false; } } }


Posts: 34
Registered: ‎07-25-2008
My Device: Not Specified

Re: Determining if application is running

Hey Guys.. THanks a tonne!

Yosoh that was the API i needed.. thanks it worked. 

And Richard, always to the rescue  Smiley Happy ... left me with no problems at all Smiley Very Happy


Tariq, I needed this to invoke a GUI application from a thread listening for a particular SMS. 


Thanks all of you...