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. This article will help you with this.
First, you have to 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 like below:
#include <appinfo.rh>
#include <uikon.rh>
RESOURCE APP_REGISTRATION_INFO
{
...
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, you shall 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
}
else
{
// App. has been auto-started -> exit if auto-start in settings is OFF
}
return CEikAppUi::ProcessCommandParametersL( aCommandLine );
}
you can also note that passing Symbian Signed requires that your application has a setting option that allow to disable the auto start feature. As no API is currently available to do this, you will need to have some code to handle this. Hopefully, this is very well explained in the Forum Nokia Technical Library (which this article is based on).
This article only applies to S60 3rd Edition and following versions which implements the Startup List API.
【
原文地址】