Hi,
I am working on 2nd edition. I have written an EXE which listens to the database and records any changes(new/modified). Right now i'm manually starting the EXE from file explorer but it can record only one change.
How can i make this EXE to always run on the phone.
Your code looks highly suspicious. Are those member variables there you are pushing to the cleanup stack (and leaving there)?? At least I do not see any local variable declarations in your code.
At least you should make changenotifier and database member variables, otherwise you'll lose the pointer to them when returning from ConstructL. Crashing is very likely due to the improper memory handling (putting/leaving objects on the cleanupstack without really understanding why). I suggest you familiarize yourself more with these topics, it will save you a lot of trouble in the future.
To clarify my comment -- you never, ever push member variables to the cleanup stack. And almost always when you are using asynchronous functionality (like notifications are) you need to put the object you are using as a member variable of some other object, which exists during the lifetime of the service you are using.
Doing long running stuff in a while loop a) wastes the battery of the device fast if it lasts long and b) will result in WSERV 11 panic, if your gui app won't respond to window server queries in 10-30 seconds. How long does your loop run?
It depends on what you are trying to accomplish. Usually you need to use the active object framework, with an active scheduler and one or more active objects, which use the asynchronous services in the OS.
Forum posts: 85
Check this out:
http://wiki.forum.nokia.com/index.php/Autostart_applications_on_S60_2nd_Edition_phones
Forum posts: 59
This will start the EXE on boot. And my problem is how can i keep it running on the phone.
Forum posts: 85
Why, what makes it close?
Forum posts: 59
Register for notification
void CntNobtobserver:: ConstructL()
{
TRAPD(err, database = CContactDatabase::OpenL());
CleanupStack::PushL(database);
if(database)
{
changenotifier =CContactChangeNotifier::NewL(*database,this);
CleanupStack::PushL(changenotifier) ;
}
}
when the contact database changes HandleDatabaseEventL(TContactDbObserverEvent aEvent) gets called
I tried to but the ConstructL() inside while(1) when calling but its crashing.
Forum posts: 672
Your code looks highly suspicious. Are those member variables there you are pushing to the cleanup stack (and leaving there)?? At least I do not see any local variable declarations in your code.
Forum posts: 85
At least you should make
changenotifieranddatabasemember variables, otherwise you'll lose the pointer to them when returning fromConstructL. Crashing is very likely due to the improper memory handling (putting/leaving objects on the cleanupstack without really understanding why). I suggest you familiarize yourself more with these topics, it will save you a lot of trouble in the future.Forum posts: 672
To clarify my comment -- you never, ever push member variables to the cleanup stack. And almost always when you are using asynchronous functionality (like notifications are) you need to put the object you are using as a member variable of some other object, which exists during the lifetime of the service you are using.
Forum posts: 59
Well, i'm deleting both the objects inside destructor .
and what about putting the constructL in while(1)
Forum posts: 672
Doing long running stuff in a while loop a) wastes the battery of the device fast if it lasts long and b) will result in WSERV 11 panic, if your gui app won't respond to window server queries in 10-30 seconds. How long does your loop run?
Forum posts: 59
hi andreas,
ya, that is very true. how to solve the issue.
regards,
Amit
Forum posts: 672
It depends on what you are trying to accomplish. Usually you need to use the active object framework, with an active scheduler and one or more active objects, which use the asynchronous services in the OS.
Forum posts: 59
Hi Andreas @ lvsti,
Thanks mate...got the problem solved .....
Regards,
Amit