×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    11

    Preventing multiple instances of an application

    Hi, I'm currently developing an application which needs to startup automatically in the background and be able to be brought to the foreground when the user selects the icon in the apps menu.

    My problem is selecting the app in the menu starts a second instance of the app, which is then sent automatically to the background.

    My understanding from searching the forums is that deriving from CAknApplication and CAknDocument is supposed to prevent this, however I'm already using both. This isn't just my application, all the example programs I compile have the same problem.

    Any suggestions at all would be appreciated.


    ---


    A second question assuming I manage to get the first part fixed, is it possible to detect when my application is brought to the foreground so some code can then be executed?

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,688

    Re: Preventing multiple instances of an application

    1) I am not sure what you mean on "deriving from CAknApplication and CAknDocument". "Real" GUI applications do not run in multiple instances, however deriving from arbitrary classes does nothing about that.
    You can use TFindProcess for checking if your code already runs or not anyway.

    2) If your application is a GUI one, AppUi::HandleForegroundEventL.

  3. #3
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: Preventing multiple instances of an application

    I'm not sure I'm understanding either. As you say, avkon performs that check for you (see CAknApplication::PreDocConstructL())

    In any case, make sure you're not messing with different UIDs in your app.

  4. #4
    Registered User
    Join Date
    Aug 2008
    Posts
    11

    Re: Preventing multiple instances of an application

    http://discussion.forum.nokia.com/fo...ad.php?t=62123

    Here somebody with the same problem fixed it by switching to CAknApplication, I'll try checking all the UIds but I'm fairly sure that isn't the problem since I'm just using the wizard generated one.

    I'll take a look at HandleForegroundEventL, thanks.

  5. #5
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: Preventing multiple instances of an application

    Also note that the check is done for non-embedded applications.

  6. #6
    Registered User
    Join Date
    Aug 2008
    Posts
    11

    Re: Preventing multiple instances of an application

    I don't understand what you mean by non-embedded applications but I searched for CAknApplication::PreDocConstructL() and I found the problem.

    I was overriding CAknDocument::UpdateTaskNameL in order to hide the application from the task list, removing this fixed everything.

    Thanks guys.

    Next, what is the correct way to hide the application from task list that doesn't mess up everything?

  7. #7
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: Preventing multiple instances of an application

    Quote Originally Posted by egawthrop View Post
    I don't understand what you mean by non-embedded applications but I searched for
    A bit outdated, but will give you an idea: http://www.symbian.com/developer/tec.../faq_1129.html
    CAknApplication::PreDocConstructL() and I found the problem.

    I was overriding CAknDocument::UpdateTaskNameL in order to hide the application from the task list, removing this fixed everything.

    Thanks guys.

    Next, what is the correct way to hide the application from task list that doesn't mess up everything?
    CAknAppUi::HideApplicationFromFSW()

  8. #8
    Registered User
    Join Date
    Aug 2008
    Posts
    11

    Re: Preventing multiple instances of an application

    Excellent, thanks again David.

Similar Threads

  1. Create Multiple instances of the same exe.
    By kdurga in forum Symbian
    Replies: 3
    Last Post: 2008-08-11, 09:10
  2. Porting existing application from Sun Wireless tookit 2.3 to Carbide.j 1.5
    By vgps in forum Tools and SDK Feedback (Closed)
    Replies: 3
    Last Post: 2007-06-30, 18:02
  3. Multiple "Allow application to read data in:" prompts
    By selenatan in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2007-06-17, 03:36
  4. Launching a view of a diffrent application
    By nsivach in forum Symbian
    Replies: 3
    Last Post: 2007-03-22, 09:51
  5. Replies: 0
    Last Post: 2005-05-28, 10:20

Posting Permissions

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