×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    7

    [HELP] Activate application failed in console mode

    Hi all, I write a console application that can running in background, and if some new SMS arrived.
    I will activate a GUI application.

    Following is the implemenation:
    TBool CDetector::StartAppL(const TDesC& aParam)
    {
    const TUid KAppUid( TUid::Uid( 0x2002A11C ) );

    RWsSession aWsSession;
    User::LeaveIfError( aWsSession.Connect() );

    TApaTaskList aTaskList( aWsSession);
    TApaTask aApaTask = aTaskList.FindApp( KAppUid );

    const TBool bIsExist = aApaTask.Exists();

    // Close the windows server session.
    aWsSession.Close();

    TInt nErrCode = KErrNone;
    if ( bIsExist )
    {
    // The application is already running.
    aApaTask.BringToForeground();

    // Send the message.
    if ( aParam.Length() > 0 )
    {
    // Convert the param to UTF-8 encoding
    HBufC8* pParam8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aParam);
    if ( NULL != pParam8 )
    {
    CleanupStack::PushL(pParam8);

    // Send the message.
    nErrCode = aApaTask.SendMessage(TUid::Uid(KUidApaMessageSwitchOpenFileValue ), *pParam8);

    // Release the instance for the buffer.
    CleanupStack::PopAndDestroy(pParam8);
    }
    }
    }
    else
    {
    RApaLsSession aApaLsSession;
    // connect to AppArc server
    User::LeaveIfError(aApaLsSession.Connect());

    // The parameter is empty.
    TThreadId nThreadId;
    nErrCode = aApaLsSession.StartDocument(aParam, KAppUid, nThreadId, RApaLsSession::ELaunchNewApp);

    aApaLsSession.Close();
    }

    return (KErrNone == nErrCode);
    }

    The problems is: If the GUI application is not launch yet, it will start through StartDocument, and it work fine.
    While the GUI app is already running. Then the console application will crash.
    And if I commented the line: SendMessage, of course, it will not crash since do nothing.

    So my question is: how can we start the application in the console mode if the GUI is already running.

    Thanks all!

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,179

    Re: [HELP] Activate application failed in console mode

    And what is the crash code ?

Similar Threads

  1. Calling Asynchronous function from console application
    By lokesh_kumar_s in forum Symbian
    Replies: 11
    Last Post: 2009-08-14, 12:46
  2. Replies: 24
    Last Post: 2008-09-14, 17:24
  3. Sensor API within console application
    By Saxer in forum Symbian
    Replies: 3
    Last Post: 2008-07-16, 13:38
  4. how to create console application phone target
    By arayappan_it in forum Symbian
    Replies: 8
    Last Post: 2008-04-25, 11:58
  5. Application crashes by soft key press in landscape mode in S60 3rd ed FP1 emulator
    By retset in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2007-11-08, 17:05

Posting Permissions

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