Reputation: 169
how to know which screen is open/ in foreground in blackberry? In other words, can we get a name of the screen which is currently open in BB. It can include other app, call logs, messages etc. , not necessarily my APP. Can this be done? Thanks..
Upvotes: 1
Views: 108
Reputation: 11876
There are three methods in ApplicationDescriptor that can help you figure out the currently foregrounded app. Getting to the Application object itself may be a little more difficult, but you can at least discover the ApplicationDescriptor.
ApplicationManager mgr = ApplicationManager.getApplicationManager();
final ApplicationDescriptor[] vApps = mgr.getVisibleApplications();
int foregroundId = mgr.getForegroundProcessId();
for(int i = 0; i < vApps.length; i++) {
int id = mgr.getProcessId(vApps[i]);
if(id == foregroundId) {
// we have a winner!
}
}
Upvotes: 1
Reputation: 68576
Hopefully this is what you mean:
if (Application.getApplication().isForeground()) {
Screen scr = UiApplication.getUiApplication().getActiveScreen();
}
Upvotes: 0