Hi
I have created a program for capturing the location when pressing a key. I have used the following code, i used an Active Object for the key press, and we need to give an active object for getting the position request. My problem is that when we are using the AO the application get terminated.Iam highlighting the lines which have problem. Please explain me how we can use two different AO's.
Please help me,,
Code:CkeyCapturer::CkeyCapturer() : CActive(EPriorityStandard) { } CkeyCapturer::~CkeyCapturer() { Cancel(); iPositioner.Close(); iLocationServer.Close(); } void CkeyCapturer::gpsL() { User::LeaveIfError(iLocationServer.Connect()); //open positioner User::LeaveIfError(iPositioner.Open(iLocationServer)); _LIT(KAppName, "HelloWorldBasic"); // set our application as location requestor User::LeaveIfError(iPositioner.SetRequestor(CRequestor::ERequestorService, CRequestor::EFormatApplication, KAppName)); // set maximum allowed time for a location request ///TTimeIntervalMicroSeconds timeOut(30000000); // 30 sec ///TPositionUpdateOptions updateOptions; ///updateOptions.SetUpdateTimeOut(timeOut); ///User::LeaveIfError(iPositioner.SetUpdateOptions(updateOptions)); } void CkeyCapturer::StartCapturingL() { //LogPrintfL(KLogFile, "CkeyCapturer: StartCapturingL...\r\n"); User::LeaveIfError(iWsSession.Connect()); iWindowGroup = new (ELeave) RWindowGroup(iWsSession); iWindowGroup->Construct((TUint32) iWindowGroup, EFalse); iCaptureHandle = iWindowGroup->CaptureKey(KKeyCode, 0, 0); User::LeaveIfError(iLongCaptureHandle = iWindowGroup->CaptureLongKey( KKeyCode, KKeyCode, 0, 0, 0, 0)); iWindowGroup->SetOrdinalPosition(-1); iWindowGroup->EnableReceiptOfFocus(EFalse); iWindowGroupName = CApaWindowGroupName::NewL(iWsSession); iWindowGroupName->SetHidden(ETrue); iWindowGroupName->SetWindowGroupName(*iWindowGroup); iWsSession.EventReady(&this->iStatus); CActiveScheduler::Add(this); SetActive(); LogPrintfL(KLogFile, "CkeyCapturer: StartCapturingL Exiting...\r\n"); } void CGlobalCapturer::RunL() { LogPrintfL(KLogFile, "CkeyCapturer: RunL err [%d]. . \r\n", iStatus.Int()); if (iStatus == KErrNone) { TWsEvent we; iWsSession.GetEvent(we); TInt keyCode = we.Key()->iCode; User::After(500); CActiveScheduler::Add(this); SetActive(); iPositioner.NotifyPositionUpdate(iPositionInfo, iStatus); TPosition pos; iPositionInfo.GetPosition(pos); aLatitude = pos.Latitude(); aLongitude = pos.Longitude(); }

Reply With Quote

