简体   繁体   中英

how to know which screen is open in blackberry?

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..

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!
   }
}

Hopefully this is what you mean:

if  (Application.getApplication().isForeground()) {
  Screen scr = UiApplication.getUiApplication().getActiveScreen()​;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM