Switching views in the view architecture

Local switching

To switch between views within an application, you can use CAknViewAppUI::ActivateLocalViewL().

An example implementation of switching between views in an application as a result of command handling is as follows:

case EMyViewAppCmdView1Cmd1:
            // Switch to view 2            

, where KView2Id is the UID for view 2 in the application, and is defined in another header filer in the application.

A new view is activated first and the previous view is deactivated after that. This allows quick view switching to take place. When deactivating, all controls, including menus and dialogs, are also closed down.

Each view may have its own menu system as defined in the AVKON_VIEW resource structure. However, if the menu system owned by the application is to be used, its contents must be updated for the new view prior to switching.

An example implementation is as follows:

// Switch to a new menu system for the new view.
// Now switch the view to view 2

Remote switching

In remote view switching, an application initiates the remote target application to change its view. If the application is not running, it is started.

In the application, call the CCoeAppUi::ActivateViewL() function, giving TVwsViewId containing the target application’s UID and the target view UID.

Optionally, if the remote application view requires, give a message ID and the descriptor data, which the view needs for its initialization. The remote application view documentation publishes the required parameters.

Note that the calling and target application are independent of each other. When the target application exits, it will not exit the calling application. Also, when the calling client exits after switching the remote view of the target application, it will not exit the target application.

Remote view switching is a one-way request through the application framework from a calling application to a target application. The caller can send data, but the target application cannot pass data back through the framework. Of course, the calling application may pass a file path, which could be used for data exchange.