How to prevent app exit by hang up key but from task list?
Login to reply to this topic.
Mon, 2007-10-15 03:58
Joined: 2007-10-15
Forum posts: 2

I have a requirement that the application should not exit while user pressed hang up key (the red key for end phone calling),
but it can be exited smoothly from the task list.

I have tried this way:
I added a flag for the AppUi that, say TBool iFromKeyEnd, initialized with EFalse, while the hang up key was pressed,
it will be set as ETrue.

Then in the void CMyAppUi::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case EEikCmdExit:
if ( EFalse == iFromKeyEnd )
Exit();
break;

// cases for other commands
// other operations
}
}

It works well while the application is ended from the task list. However, while I pressed the hang up key, then the
application will be switched to the background, then I try to kill it from the task list, I found that it CAN NOT be
exit !!!

And I have logged and found that after the hang up key was pressed, and the codes in case EEikCmdExit will be
executed, however, it will do nothing since iFromKeyEnd == ETrue.
After that, when delete the application in the task list to exit it. I found that the codes for EEikCmdExit will not be
executed again.

Does anyone know the reason? And is there any better solution for this requirement?
Thanks a lot !


Mon, 2007-10-15 13:59
Joined: 2004-11-29
Forum posts: 1419

My guess (if I have understood your problem correctly) is that you simply forget to reset the iFromKeyEnd variable at some suitable point.

Am I right you set this value in your OfferKeyEventL()?
In what cases are the flag reset back to EFalse?
Will this case(s) happen between you pressing hang-up to switch it to background and you trying to exit from appswitch menu?

Mon, 2007-10-15 16:32
Joined: 2007-10-15
Forum posts: 2

Hi alh, the problem is not as you mentioned. I have set the flag, say iFromKeyEnd, to EFalse while other
key pressed in the OfferKeyEventL.
void CMyAppUi::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case EEikCmdExit:
{
// I add codes here, to log the code
CMyLog("Try to Exit the application"); // CMyLog is the macro defined for logging the text to file.
if ( EFalse == iFromKeyEnd )
Exit();
}
break;
}
}

That is, we first pressed the hang up key, the "Try to Exit the application" will be logged to the file.
Then try to exit the application from task list, I found it is strange that the log text will not be wrote
in the log file.

Is it the reason for the framework for Symbian, the EEikCmdExit event will be only sent once to the
application?? Or something else wrong??


copyright 2003-2009 NewLC SARL