Search code examples
blackberryforeground

Blackberry Application.activate() not triggering


I'm calling Application.getApplication().requestForeground(); from a Background Class extending from Application. But this function is not triggering. This function is also in the same Background Class.

        public void activate(){
             System.out.println("==Activate== ");
        }

        public void setupBackgroundApplication(){ 
             Application.getApplication().requestForeground();
        }

How can this activate function can trigger?


Solution

  • I think the problem may be that there are two different concepts here:

    • Application, which is the base class of all BlackBerry Java applications (UI and background apps)

    • UiApplication, which is the base class of BlackBerry Java UI applications.

    If your application is a subclass of Application:

    public class MyApplication extends Application {
    

    then, calling requestForeground() isn't going to magically give it a user interface.

    My guess is that you need one of two solutions:

    1. If you want one application, then change it to extend UiApplication. You will then have one application, that goes from foreground to background to foreground ...

    2. You could use two applications, one which always runs in the background, and another which is only a UI application. Then, your background code could trigger the UI application with the ApplicationManager APIs