Friday, August 03, 2007

How to detect if an application is launched by user or the startup list

It is sometimes useful to be able to detect whether an application is started at boot time by the Startup List API (present only in S60 3rd Edition) or by the user, and passing Symbian Signed - which is generally required to have an application which requires auto boot feature - makes this almost mandatory. So How we can archive it let us try

First, we will modify the application registration file and add some opaque_data field in the APP_REGISTRATION_INFO resource. The content and value of these data does not really matter, you just need to specify something: :

#include <appinfo.rh>
#include <uikon.rh>

opaque_data = r_startup_detect;

RESOURCE NUMBER_INT8 r_startup_detect
value = 1;

The opaque_data and other launch parameters will be ignored by the startup list when launching the application. Thus, detecting whether they are present or not allows to differentiate whether the application has been launched at boot time or by the user.

To do this, we will override the ProcessCommandParametersL() function in your AppUI:

TBool CMyAppUi::ProcessCommandParametersL( CApaCommandLine &aCommandLine )
if(aCommandLine.OpaqueData().Length() > 0)
// Opaque data exists,
// app. has been manually started from the menu
// Opaque data not present,
// App. has been auto-started from start up
// or after Installation !!!
return CEikAppUi::ProcessCommandParametersL( aCommandLine );

No comments:

stats counter