Display a dialog when the application starts
Due to the asynchronous nature of the AVKON/EIKON framework, the active scheduler needs to have at least one reschedule to setup all the components of the framework correctly. This means it is very bad practice to block the application in the ConstructL call to display a dialog.
The correct way is to create an active object that is triggered when there are no outstanding requests in the active scheduler and this displays the dialog correctly and ensures features such as the background are not white.
Three methods are typically needed. They are as follows:
1. void AddInitialCallbackL()
This creates the callback, links it to an object and adds the callback object to the active scheduler.
// This sample is added to the view class of the application,
// though it could equally as well be added to the appui
// This is called from the DoActivateL of the view class.
TCallBack callback(StartupCallback, this);
iCallback = new (ELeave) CAsyncCallBack(callback, CActive::EPriorityIdle);
// Most people forget the step below, this schedules the active object!
2. static TInt StartupCallback(TAny* aAny)
The actual callback object function. The parameter passed in is the object so this can be cast to the correct type and then the method on that object can be called.
TInt CView::StartupCallback(TAny* aAny)
CView* view = REINTERPRET_CAST(CView*, aAny);
3. void DoStartupCallbackL()
The actual implementation of the callback that is in the object. This can do various things including kicking off another active object.
CAknInformationNote* note = new (ELeave) CAknInformationNote(ETrue);