On Tue, 02 Dec 2003 17:58:01 +0200, Eugene Mayevski wrote:

> Hello!
> 
> If my application is active, how can it receive notification that the device
> is suspended? I checked SysNotifyRegister function but it seems to launch an
> application (with specific launch code), when the device is suspended. And I
> need to shutdown existing application, which is currently active. Can you
> please point me in the right direction? Thanks in advance.
> 
> Sincerely yours,
> Eugene Mayevski

I have been working with the new Aceeca Meazura unit (palmos 4.1.2) and
I need to be able to turn power on and off to the external module, so this
is what I do when the unit goes to sleep, with notifications (4.0 >):

// in start application code
        // Register for sleep and wake notifications
        dbID = DmFindDatabase (0, appName);
        userDataP = MemPtrNew(10);
        error = SysNotifyRegister (0, dbID, sysNotifySleepNotifyEvent, 
        NULL, sysNotifyNormalPriority, userDataP);
        error = SysNotifyRegister (0, dbID, sysNotifyLateWakeupEvent, 
        NULL, sysNotifyNormalPriority, userDataP);

UInt32 PilotMain(UInt16 cmd, MemPtr startP, UInt16 launchFlags)
{
        Err                     error;
        Boolean                 tempB;
        SysNotifyParamType*     notifyP = (SysNotifyParamType*) startP;

        switch (cmd)
        {
        case sysAppLaunchCmdNormalLaunch:
                // Application start code
                error = StartApplication();
                if (error)
                        return error;

                // Maintain event loop
                EventLoop();

                // Stop application
                StopApplication();
                break;

        case sysAppLaunchCmdNotify:
                switch (notifyP->notifyType)
                {
                case sysNotifySleepNotifyEvent:
                        ser_close();
                        // insert your sleep code here
                        notifyP->handled = false;
                        break;
                case sysNotifyLateWakeupEvent:
                        // insert your wakeup code here
                        notifyP->handled = false;
                        break;
                default:
                        break;
                }
        default:
                break;
        }
        return 0;

And dont forget to unregister when exiting:

        // Unregister all the notifications
        dbID    = DmFindDatabase (0, appName);
        error = SysNotifyUnregister(0, dbID, 
        sysNotifySleepNotifyEvent,      sysNotifyNormalPriority);
        error = SysNotifyUnregister(0, dbID,sysNotifyLateWakeupEvent,
        sysNotifyNormalPriority);

Hope this helps

Terry Markovich

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to