×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    287

    Active Object Error??

    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();
    	
    
    }

  2. #2
    Nokia Developer Champion
    Join Date
    Jul 2004
    Posts
    2,015

    Re: Active Object Error??

    You only add an active object to the scheduler once, you are adding them more than once.

    Wizard has already said in your other posting that adding to the active scheduler should be done in the constructor, so it is surprising that you choose to ignore his comments.

    P.S.
    I never understand why people do this->iStatus instead of just iStatus? Why the need for this?
    Last edited by hotcheese; 2009-06-24 at 20:56.

Similar Threads

  1. [newbie here] Link error
    By xitpu in forum Symbian
    Replies: 3
    Last Post: 2007-01-24, 16:53
  2. carbide build problem help please
    By berkcekisbas in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2006-09-26, 19:41
  3. problem with Code Warrior 5.2
    By mayankkedia in forum Symbian
    Replies: 4
    Last Post: 2006-06-22, 08:26
  4. My BuilderX (with S60 SDK 2.1.NET MS version) cannot build ARMI UREL
    By danielvidonyi@hotmail.com in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2006-05-04, 21:30
  5. how to avoid linking error
    By skdas in forum Symbian
    Replies: 6
    Last Post: 2003-07-07, 07:57

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×