Enumerating Applications

Device creators can use the APIs provided by APPARC to enumerate a list of applications on a device.


  1. Create a session with the APPARC server using the RApaLsSession::Connect().
    RApaLsSession apaLsSession;  
    
    // Connect to the APPARC server
    User::LeaveIfError(apaLsSession.Connect());
    

  2. Implement one or more of the following functions as per your requirement:

    1. RApaLsSession::GetAllApps() - Use this function to initialize the process of getting all applications in the list except the control panel applications.

    2. RApaLsSession::GetEmbeddableApps() - Use this function to initialize the process of getting all the embeddable applications in the list except the control panel applications.

    3. RApaLsSession::GetFilteredApps() - Use this function to initialize the process of getting all the filtered applications in the list except the control panel applications.

    4. RApaLsSession::GetServerApps() - Use this function to initialize the process of getting all the server applications in the list except the control panel applications.

  3. Call the RApaLsSession::GetNextApp() to get one application at a time. The RApaLsSession::GetNextApp() must be called in loop to get information about the next application in the list. The application information is stored in TApaAppInfo variable. If there are no more applications present in the list, ENoMoreAppsInList message is returned. The following code snippet shows how to get a list of all the applications on the device:
    // Get the list of all the applications on the device
    
    TInt ret = apaLsSession.GetAllApps();
    if(ret==KErrNone)
       {                
        TApaAppInfo appInfo;
    
        // Retrieve the next application in the list.
                // appInfo contains the application information
     
        while((ret= apaLsSession.GetNextApp(appInfo)) == KErrNone);
    
    
        // Make sure ENoMoreAppsInList is returned at the end of list.
    
        if(ret==RApaLsSession::ENoMoreAppsInList)
          {
             // No more applications in the list
          }
        }
    The following code snippet shows how to get a list of all the server applications on the device:
    // Get the list of all the server applications on the device
    
    TInt ret = apaLsSession.GetServerApps();
    if(ret==KErrNone)
       {                
        TApaAppInfo appInfo;
    
        // Retrieve the next application in the list which provides a service.
    
        while((ret= apaLsSession.GetNextApp(appInfo)) == KErrNone);
    
    
        // Make sure ENoMoreAppsInList is returned at the end of list.
    
        if(ret==RApaLsSession::ENoMoreAppsInList)
          {
             // No more server applications in the list
          }
        }
    The following code snippet shows how to get a list of all the embedded applications on the device:
    // Get the list of all the embedded applications on the device
    
    TInt ret = apaLsSession.GetEmbeddedableApps();
    if(ret==KErrNone)
       {                
        TApaAppInfo appInfo;
    
        // Retrieve the next embedded application in the application list 
    
        while((ret= apaLsSession.GetNextApp(appInfo)) == KErrNone);
    
    
        // Make sure ENoMoreAppsInList is returned at the end of list.
    
        if(ret==RApaLsSession::ENoMoreAppsInList)
          {
              // No more embedded applications in the list
          }
        }
    The following code snippet shows how to get a list of all the filtered applications on the device:
    // Get the list of all the application based on the filter defined in the parameter passed to it.
    
    TApaEmbeddabilityFilter &filter = TApaEmbeddabilityFilter();
    filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiOrStandAlone);
    
    TInt ret = apaLsSession.GetFilteredApps(filter);
    if(ret==KErrNone)
       {                
        TApaAppInfo appInfo;
    
        // Retrieve the next application in the application list that matches the specified filter.
    
        while((ret= apaLsSession.GetNextApp(appInfo)) == KErrNone);
    
    
        // Make sure ENoMoreAppsInList is returned at the end of list.
    
        if(ret==RApaLsSession::ENoMoreAppsInList)
          {
             // No more filtered applications in the list
          }
        }