If you would like to start the appropriate Launcher application, there are
two ways to accomplish this, depending on whether your current app has an
event loop:

If your current app *has* an event loop:
----------------------------------------
Execute the code snippet below (from Developing Palm OS 3.0
Applications Part II: System Management), and continue with your event loop
as normal.  The system will soon send your application the "appStopEvent",
at which time your app can terminate normally, and the correct thing will
happen.  This is the preferred method, as the system should be able to take
care of it in the
most appropriate way.  It may even be worth it to enter a simple event loop
(even if you don't otherwise have/need one) and wait for appStopEvent after
executing this code, just to avoid hacking it yourself.
>>>>>>>
Listing 1.13 Opening the Launcher
EventType newEvent;
newEvent.eType = KeyDownEvent;
newEvent.data.keyDown.chr = launchChr;
newEvent.data.keyDown.modifiers = commandKeyMask;
EvtAddEventToQueue (&newEvent);
<<<<<<<


If your current app does *not* have an event loop:
--------------------------------------------------
You need to do something like this (I have not tested it, but it should give
you the general idea):

  #include <preferences.h>

  DWord appCreator;
  Err   tmpErr = 0;
  DmSearchStateType state;
  Word  cardNo;
  LocalID dbID;

  appCreator = PrefGetPreference (prefLauncherAppCreator);
  if (!appCreator ) 
        appCreator = 'lnch';

  tmpErr = DmGetNextDatabaseByTypeCreator (true, &state, 
                sysFileTApplication, appCreator, 
                true, &cardNo, &dbID);

  // If error, look explicitly for the system app launcher
  if (tmpErr != 0)
    {
        appCreator = 'lnch';

      tmpErr = DmGetNextDatabaseByTypeCreator (true, &state, 
                    sysFileTApplication, appCreator, 
                    true, &cardNo, &dbID);
    }

  // If we didn't find the appropriate launcher app, request default action
from the system
  if (tmpErr != 0)
    {
      cardNo = 0;
      dbID = 0;
    }

  // Now, do the switch
  SysUIAppSwitch (cardNo, dbID, sysAppLaunchCmdNormalLaunch, 0);


Hope this helps,

Vitaly

-----Original Message-----
From: David Fedor [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 05, 2000 10:51 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Application invoking loop on Visor


>Our Visor card has a startup program that does something small and then
>launches another program.
>When the second program exits (normally), the starter program is
>automatically
>launched and the whole things starts over again.

Well, as I'm sure you know, the normal practice of a Palm OS application is
to not exit, until/unless the user chooses another application to launch.
The "run the last app" is simply a fallback technique for when apps quit of
their own accord, without specifying what app to launch next.  So
"normally" isn't the word to use in this situation, if the user didn't tap
"applications" :-)

Sounds like your second application isn't a standard kind of UI application
which runs for some period of time, right? Some sort of "second half" of
the startup app, to initialize the card or hardware or whatever?

I don't know the specifics of your application, but perhaps your starter
program should just do a sublaunch of your small second program, so that
the starter can then exit back to the app that the user was running before
they dropped in your card.  It depends on what your card is, what it does,
what your second program is and does, and what the user would want to have
happen.

If all else fails you could have the startup app look at the system's
global variable indicating what was the previously running app, so it could
tell the second app, so the second app could launch it when it was done.
That's ugly, and would not be guaranteed to work in the future.  If
possible, go for a sublaunch of the second app.

-David Fedor
Palm Developer Support


Reply via email to