×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Hyderabad, India
    Posts
    90

    Question Bringing application to foreground

    Hi,

    My intention is to bring my application to foreground when a specific key is pressed. I know this has been discussed a number of times on the forum, but unfortunately its not working. Here is what I am doing. This is working fine on the emulator but not working on the device. Any clue why? I am using E61 & N73 to test.

    void CHighPrioAppUi::ConstructL()
    {
    BaseConstructL();

    iAppView = CHighPrioAppView::NewL(ClientRect());

    AddToStackL(iAppView);

    // set application as system application so that it will not be closed by
    // system events
    CEikonEnv::Static()->SetSystem( ETrue );

    // capture red key permanently
    iHashKeyHandle = CEikonEnv::Static()->RootWin().CaptureKeyUpAndDowns(EStdKeyHash, 0, 0);

    // set application priority to foreground priority even if it goes to background
    CEikonEnv::Static()->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled );

    // Make the application a high priority application
    CEikonEnv::Static()->RootWin().EnableReceiptOfFocus( ETrue );
    CEikonEnv::Static()->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
    }

    CHighPrioAppUi::~CHighPrioAppUi()
    {
    CEikonEnv::Static()->RootWin().CancelCaptureKeyUpAndDowns(iHashKeyHandle);

    if (iAppView)
    {
    RemoveFromStack(iAppView);
    delete iAppView;
    iAppView = NULL;
    }
    }

    void CHighPrioAppUi::HandleForegroundEventL (TBool aForeground)
    {
    // Make the application a high priority application
    if (aForeground)
    {
    CEikonEnv::Static()->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
    }
    }

    // Handle Key Events in this
    void CHighPrioAppUi::HandleWsEventL (const TWsEvent &aEvent, CCoeControl *aDestination)
    {
    if (aEvent.Type() == EEventKey ||
    aEvent.Type() == EEventKeyUp ||
    aEvent.Type() == EEventKeyDown ||
    aEvent.Type() == EEventKeyRepeat)
    {
    // This is for switching back to Application when Hash key is pressed
    if (EStdKeyHash == aEvent.Key()->iScanCode && EEventKey == aEvent.Type())
    {
    TApaTask task(iEikonEnv->WsSession());
    task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
    task.BringToForeground();

    return;
    }
    }

    CAknAppUi::HandleWsEventL(aEvent, aDestination);
    }
    Regards,
    Ashish

  2. #2
    Registered User
    Join Date
    Jul 2005
    Location
    Bengaluru, India
    Posts
    747

    Re: Bringing application to foreground

    I found the solution, it was because we didn't include the SwEvent capability in the MMP file.

Similar Threads

  1. Cannot launch application after installation
    By Gayathri Lokesh in forum General Development Questions
    Replies: 0
    Last Post: 2006-01-05, 14:00
  2. Application skips many times when I click the application
    By bb_sathya in forum Mobile Java General
    Replies: 0
    Last Post: 2005-12-20, 04:49
  3. Changing the ordinal position of an exteranl application.
    By Shaikuny in forum Symbian User Interface
    Replies: 1
    Last Post: 2004-12-30, 07:32
  4. Replies: 0
    Last Post: 2004-12-13, 11:05
  5. Replies: 0
    Last Post: 2003-02-03, 08:08

Posting Permissions

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