I need to lookup a contact in the Treo 650 address book when my application is
launched from a launch code other than sysAppLaunchCmdNormalLaunch. The code
from this post(see below) works great when my app is running from a
sysAppLaunchCmdNormalLaunch, but otherwise the line:
err = SysAppLaunchSysAppLaunch(cardNo, dbID, 0, sysAppLaunchCmdNotify,
(MemPtr)¶ms, &result);
results in a crash:
datamgr.c, Line:8898, DmWrite:DmWriteCheck failed.
The next time I call the app (even from the normal launch code) results in a
BadDBRef error, crashing the Treo650 simulator. Does anyone know what is
causing this problem or if there is another way to access phone book contacts
that I can try to work around this? (BTW if I run this on the phone it appears
to work correctly)
thanks, Michael
static Boolean callbackFunc(void* ref)
{
return false;
}
Char* Lookup(UInt16 utilsLibRef, const char * number) // number should be a
straight 11 digit number like 18005551212
{
DmSearchStateType stateInfo;
UInt16 cardNo;
LocalID dbID = NULL;
UInt32 result;
Err err;
UInt32 dbCreator = 'PAdd';
UInt32 plainVal = 0;
SysNotifyParamType params;
AddrCallerIDParamsType lookupParams;
Char* numberCpy = UtilsLib_CopyStringPointer(utilsLibRef, number);
MemSet(¶ms, sizeof(params), 0);
MemSet(&lookupParams, sizeof(lookupParams), 0);
params.notifyType = addrAppNotificationCmdCallerID;
params.notifyDetailsP = &lookupParams;
lookupParams.lookupString = numberCpy;
lookupParams.formatString = "^name"; // you can change this to whatever
you want
lookupParams.callback = callbackFunc;
lookupParams.ref = (void*)&plainVal;
err = DmGetNextDatabaseByTypeCreator(true, &stateInfo,
sysFileTApplication, dbCreator, true, &cardNo, &dbID);
if (err)
{
dbCreator = 'addr';
err = DmGetNextDatabaseByTypeCreator(true, &stateInfo,
sysFileTApplication, dbCreator, true, &cardNo, &dbID);
}
ErrNonFatalDisplayIf(!dbID, "Could not find app");
if (dbID)
{
err = SysAppLaunch(cardNo, dbID, 0, sysAppLaunchCmdNotify,
(MemPtr)¶ms, &result);
ErrNonFatalDisplayIf(err, "Could not launch app");
}
MemPtrFree(numberCpy);
if(lookupParams.resultString)
{
return lookupParams.resultString;
}
else
{
return NULL;
}
}
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/