Querying a Single Feature Dynamically Using RFeatureControl

How to query a feature using RFeatureControl dynamically.

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


  1. Create an instance of RFeatureControl,
    
    // replace <featureUID> with a real Uid ) 
    #include <featurecontrol.h>
    #include <featureinfo.h> // for feature definitions
    CMyClass::MyMethodL()
         {
         // Replace KFeatureUidx with real feature Uid.
         // Open() must be called before calling any other methods. 
         // Disconnect is done by calling the Close() method.
         RFeatureControl featureControl;

  2. call its Open() function,
    
         TInt err = featureControl.Open();
    

  3. determine the Uid of the feature you wish to query,

  4. call the FeatureSupported() function of the RFeatureControl object with the Uid of the feature as argument, and
    
         if ( err == KErrNone )
             {
             // Query single feature status
              err = control.FeatureSupported( KFeatureUid3 );
              if( err == KFeatureSupported )
                  {
                  // do something with enabled feature
                  }
    
    

  5. call the Close() function of the RFeatureControl object.
    
             // Remember to call CloseL after using RFeatureControl.
             // It disconnects the Feature Manager server.
             featureControl.Close();  
             }
    

FeatureSupported() returns:

RFeatureControl has a deprecated function Connect() which should no longer be used as it has been replaced by the function Open().