最近整了一个brew后台运行的demo,在此mark下要点,作为备忘。也提醒自己,不能荒废了时间!
http://www.vckbase.com/document/viewdoc/?id=1469,主要看了这篇文章,才对后台有所了解,制作了demo。
摘录主要代码如下:
Examples 实例
Assume the following applet structure: //假设如下应用结构。 typedef struct _bgApp { AEEApplet a; boolean m_bGoBg; // used to toggle whether to run in background mode,后台运用的标志状态。 } bgApp; Model event handling for a background application: //后台运用的事件处理模型 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) *((boolean*) dwParam) = FALSE; // set dwParam to run in bg ,后台运行了 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; }
本人有点小笨,刚开始看懂了,但还是无法下手,犹豫过多。最终是在EVT_APP_STOP:这个事件中处理后台的逻辑。