If your phone has a camera, nomrally if you open the camera cover{at least in my N70}, 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.
1 comment:
EKeyDevice1D is probably only for your particular device? It'd be smashing to get the whole bunch of them for different devices. We have a couple here (at range of 10..20 Nokia models I'd guess); if you're equally interested in subject, you could give a short piece of code and we could test out to get the model-specific codes.
Post a Comment