If your phone has a camera, nomrally if you open the camera cover, there will be a build-in app to be launched to captrue phones. But when you write your own camera apps, you might not want the build-in app to be launched, how to do this?
The theory is quite simple, camera cover open/close event is actually a KeyEvent, if you can capture this KeyEvent which window server dispatchs inside your application, you can prevent the default app being launched. Here's how:
void CHelloWorldAppUi::HandleForegroundEventL( TBool aForeground )
{
if( aForeground ) // switch to the foreground
{
iForeground = ETrue;
iOpenCameraKey = iEikonEnv->RootWin().CaptureKey( EKeyDevice1D, 0, 0 );
}
else
{
iForeground = EFalse;
iEikonEnv->RootWin().CancelCaptureKey( iOpenCameraKey );
}
}
It doesn't make sense if you capture this KeyEvent all the time, so I capture the key when my app is in foreground, release the key when my app is in background. So the default could be autostarted when this app is in backgrond.
This code is tested under P990i(UIQ 3.0)
From ZiTeng: You omitted an important information: the CaptureKey() requires SwEvent capability, that is to say an application muse be Symbian signed to use it.