Querying a Single Feature Dynamically Using CFeatureDiscovery

How to query a feature using CFeatureDiscovery dynamically.

To query whether a feature is supported using CFeatureDiscovery dynamically, take the following steps.


  1. Determine the Uid of the feature.
  2. Create an instance of CFeatureDiscovery thus,
    
      // Dynamic way of using the class using NewL():
      
      // Call NewL() to create an instance of CFeatureDiscovery. 
      CFeatureDiscovery* testA = CFeatureDiscovery::NewL();
    
    or thus
    
      // Dynamic way of using the class using NewLC():
    
      // Call NewLC() to create an instance of CFeatureDiscovery.
      // The method leaves the instance of the object on the cleanup stack.
      CFeatureDiscovery* testB = CFeatureDiscovery::NewLC();
    
  3. call its IsSupported() function with the Uid of the feature as argument, and
      // Call the exported IsSupported() method to query whether features 
      // are supported in the current environment or not.
      TBool usbSupported = testA->IsSupported(<featureUIDx>);
      TBool mmcSupported = testA->IsSupported(<featureUIDx>);
    

  4. delete the instance of CFeatureDiscovery if it was not created using NewLC().
      // Delete the created instance of CFeatureDiscovery.
      delete testA;
    

IsSupported() returns KErrNone if the feature is supported or else an error message.