I'm writing a utility for the Treo 600 that needs to be disabled when
the Phone app is running. My utility is run mostly from within the
context of a notification handler. From within this context, I need a
foolproof way of determining which application the user is currently
interacting with. If this application is the Phone app, I want to
return immediately without doing anything. I would appreciate some
suggestions for acquiring this information.
There are a couple of ways to tell which app the user is currently
interacting with that I know of, but all have been problematic for me.
I will summarize below.
1) SysAppCurDatabase() is the obvious choice. However, because my util
makes this call during a notification, this API simply returns the
cardno / dbID of my util! This is expected, because the program counter
is situated inside of my util's code segment when this API call is made.
However, I need to know which application the user is currently
interacting with, not which application is currently executing.
2) Tracking the sysNotifyAppLaunchingEvent and sysNotifyAppQuittingEvent
is a more complicated system. Basically, here's what I do:
On sysNotifyAppLaunchingEvent:
* Use DmDatabaseInfo() to get the type and crId of the launched app;
stash in kMyFtrType and kMyFtrCrID
On sysNotifyAppQuittingEvent:
* Nullify the features to prevent them from containing stale data:
* kMyFtrType <- NULL
* kMyFtrCrID <- NULL
These notifications seem a little buggy. If the Treo 600 has entered
sleep mode from, say, Calculator, and a phone call wakes it up, these
will be set to NULL values. To investigate why, I removed my
appQuittingEvent handler -- when the phone call wakes it up, these
values will be stale and still set to Calculator (which is incorrect),
even though the Phone application is running. I infer that the
appQuitting event occurred, but in handling the incoming call, no
appLaunching event ever occurred... perhaps indicating the phone app was
sublaunched, or perhaps indicating a bug in these two notifications.
3) Treo-specific. Keep track of the numerous PhoneLib notifications to
infer when the Phone app is being used to place / receive / disconnect a
call, place / receive / disconnect a conference call, connect to voice
mail, etc etc. This becomes quite complicated, and is subject to bugs
in the Treo 600 SDK.
4) I read a thread about using DmNextOpenResDatabase() (
http://www.escribe.com/computing/pcpqa/m80412.html ), which I will try
next. I am not sure if this is a foolproof way of doing what I need,
though.
5) Call FrmGetTitle( FrmGetActiveForm() ), and maintain a list of form
titles <-> applications. Very ugly hack.
Any ideas?
Thanks for your help!
-Jeff Ishaq
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/