This is your resource to discuss support topics with your peers, and learn from each other.
07-28-2008 02:46 AM
Hi
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
)
Thanks in advance
Shraddha
Solved! Go to Solution.
07-28-2008 03:42 AM
why dont you use runtime store to do this. take a look at this BB article which does something similar.
regards,
yosoh
07-28-2008 08:59 AM
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.
Tariq
07-28-2008 12:21 PM
Hey Shraddha, how's it going?
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(module; } } }
07-29-2008 05:44 AM
Hey Guys.. THanks a tonne!
Yosoh that was the API i needed.. thanks it worked.
And Richard, always to the rescue
... left me with no problems at all
Tariq, I needed this to invoke a GUI application from a thread listening for a particular SMS.
Thanks all of you...