Brew advanced and proficient-3G mobile value-added business operation, customization and development-83-brew background applications

Source: Internet
Author: User

Earlier than brew 3.x, background applications did not respond to suspend and resume events at all, and also handled interactive operations related to end users, such as key events.

After brew 3.x, any application can process the key event, which can be simply implemented by registering a notification with the nmask_shell_key mask. Use the ishell_startbackgroundapplet () to directly start a background application. The background application can directly process the evt_app_start_background event rather than the evt_app_start event. In brew 2. in X, you can set * (dwparam) to false when you call ishell_closeapplet () and receive evt_app_stop, for example (* (oolean *) dwparam) = false.

A brew application communicates with a background application, or the background application and another background application by event transmission. There are three conditions for terminating the background running status of a background application. The first is to receive events from other applications. The other is to call the ishell_closeapplet () the other is that the background application calls ishell_startapplet () to make itself in the foreground running state, and then closes itself through user interaction.

The following is an example of using backend applications in brew2.x:

Typedef struct _ bgapp



Oolean m_bgobg; // used to toggle whether to run in background Mode

} Bgapp;


Switch (ecode)


Case evt_app_start:

If (PME-> m_bgobg)

Ishell_closeapplet (PME-> A. m_pishell, false); // send applet to background

Return true;

Case evt_app_stop:

If (PME-> m_bgobg)

* (Oolean *) dwparam) = false; // set dwparam to run in BG

Return true;

Case evt_user:

If (PME-> m_bgobg)


PME-> m_bgobg = false;

Ishell_startapplet (PME-> A. m_pishell, aeeclsid_bgapp); // make applet active

} Else {

PME-> m_bgobg = true;

// Trigger evt_app_stop to send app to background

Ishell_closeapplet (PME-> A. m_pishell, false );


Return true;


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.