Up to: Mika Raento's Symbian Programming pages

Symbian Programming - Starting applications automatically

3rd edition

On 3rd edition starting applications on device start is a supported feature of the platform, the Startup List.

1st/2nd edition

NOTE: although the instructions on this page work (for sufficiently narrow values of 'work'), they are suboptimal. Go grab our sources and look at autostart and starter code. The main difference is that you should wait until the PIN has been entered before starting your app.

Shaikh Shuja parvez rafiuddin wrote detailed instructions for using this code for your own application.

Note also that from 7.0 on (Series 60 version 2), you can use the Symbian Start-On-Boot API. You'll still have to code your own watchdog, though.

There seems to be only one way to autostart third-party applications on the Series 60 version 1: writing a recognizer. A recognizer is basically a dll (containing a class) meant to handle certain kinds of documents or files. We are not really interested in handling files, but recognizers are loaded at start up so we can embed code in one that starts the application(s) we want.

The basic requirements for a recognizer are:

  1. targettype MDL
  2. targetpath \system\recogs
  3. first uid 0x10003A19
  4. implement a class deriving from CApaDataRecognizerType
  5. implement GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
  6. implement EXPORT_C CApaDataRecognizerType* CreateRecognizer() that creates an instance of your class

Now you can put whatever code you want in CreateRecognizer(), for instance starting an app. As I understand it, this function is called in the context of some startup application, so you cannot block indefinitely. Instead the best way is to spawn another thread, return after that and have the new thread do the work.

In our project we actually use a watchdog that also restarts our application if it crashes. So we start the watchdog from the recognizer, and the watchdog starts the app.

Something to note is that it's not a good idea to start an application before the phone has booted completely, since not all services are yet available when the recognizers are loaded. Instead wait a while, it seems that 45 seconds is quite safe (a nicer way would probably be to wait until one of the system apps has started and start yours after that).

Example code

The example code is put in public domain: you may use it in any way you want.

Notable is also the structure of the watchdog. It is built as an EXEDLL, which means it's an exe for the phone and a dll for the emulator. It has the same first UID as an app. Now if we copy it to the emulator's \system\apps\starter as starter.app (note changing the extension) it can be started in the emulator by selecting it in the menu, so we can debug it. Of course starting it from the autostarter must be done differently depending on whether it's running on the phone or in the emulator. There is #ifdefed code that accomplishes this.

The EXEDLL must also implement two different entrypoints: EXPORT_C TInt InitEmulator() for the emulator and GLDEF_C TInt E32Main() for the actual phone. These must set up a CTrapCleanup before they can call any other Symbian code, and the code must be called within a TRAP.


Mika Raento, mikie(at)iki.fi