Question

I know the Brew application have 3 types: active, suspend & background. Launch one BREW application as active or suspend is very simple. I know in BREW2.0 and later version, there is a new application type can allow we create one application in the background. It will not stay in the application stack and change status by active or resume command. It will always stay in the background no matter what user command system received. In one of my small project, I need to create and launch one background application like this.

Unfortunately, I cannot find a simple example on Qualcomm or Google. Is there any programmer who has encountered the same problem?

Was it helpful?

Solution

Yes, you are right. BREW2.0+ do support background application.

When we initial a background application, just like other normal new application, it can be launched by the brew application interface directly. You also can launch it by ISHELL_StartApplet function.

When you want to put one brew application in the background, you need do it when handle EVT_APP_STOP event and must set dwParam to false. After handling EVT_APP_STOP by this, the application will be put in the background. And if you want to change it to normal application, you need call ishell_StartApplet function to active to itself again.

Example code:

    typedef struct _bgApp
    {
        AEEApplet a;
        boolean m_bGoBg;
    } bgApp;

    switch (eCode)
    {
    case EVT_APP_START:
        if(pMe->m_bGoBg)
            ISHELL_CloseApplet(pMe->a.m_pIShell, FALSE); 
    case EVT_APP_STOP:
        if(pMe->m_bGoBg)
            *((boolean*) dwParam) = FALSE;
        return TRUE;
    case EVT_USER:
        if(pMe->m_bGoBg)
        {
            pMe->m_bGoBg = FALSE;
            // make applet active
            ISHELL_StartApplet(pMe->a.m_pIShell, AEECLSID_BGAPP);   }
        else
        {
            pMe->m_bGoBg = TRUE;
            // trigger EVT_APP_STOP to send app to background
            ISHELL_CloseApplet(pMe->a.m_pIShell, FALSE); 
        }
        return TRUE;
    }      

There is a limitation of background application. You cannot change the screen or communicate with user directly. Developer should be careful on the memory used by the background application. This is very important.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top