Component Manager
The component manager provides information about installed and running components.
The main features of the Tizen.Applications.ComponentBased.ComponentManager
class includes the following:
-
Managing running component context
For the running components, you can retrieve the component running context and operate on it. You can manage the component running context with the
Tizen.Applications.ComponentBased.ComponentManager
class. -
Managing component information
For components that are installed but not necessarily running, you can retrieve information with the Tizen.Applications.ComponentBased.ComponentInfo class.
Iterator methods are used to travel through a list of components. The GetRunningComponentsAsync()
method of the Tizen.Applications.ComponentBased.ComponentManager
class is used for the running components and the GetInstalledComponentsAsync()
method is used for the installed components.
Prerequisites
To enable your application to use the component management functionality, follow these steps:
-
To use classes and methods, the application has to request permission by adding the following privilege to the
tizen-manifest.xml
file:XMLCopy<privileges> <privilege>http://tizen.org/privilege/appmanager.launch</privilege> <privilege>http://tizen.org/privilege/packagemanager.info</privilege> </privileges>
-
To use the methods and properties of the Tizen.Applications.ComponentBased.ComponentManager, Tizen.Applications.ComponentBased.ComponentRunningContext, and Tizen.Applications.ComponentBased.ComponentInfo classes, include the Tizen.Applications.ComponentBased namespace in your application:
C#Copyusing Tizen.Applications.ComponentBased;
Manage running component context
To get the running component context and its details, and to operate on the context, follow these steps:
-
Get the context of the currently running component by creating an instance of the Tizen.Applications.ComponentBased.ComponentRunningContext class, with the ID of the context obtained component as a parameter.
To get a component’s context, the component must be running:
C#CopyComponentRunningContext compoRunningContext = new ComponentRunningContext(Your Component ID);
-
Operate on the context:
-
Get the component ID, application ID, and instance ID from the context:
C#Copystring componentId = compoRunningContext.ComponentId; string applicationId = compoRunningContext.ApplicationId; string instanceId = compoRunningContext.InstanceId;
-
Check the state of the component:
C#Copyif (compoRunningContext.State == ComponentRunningContext.ComponentState.Initialized) /// The component is constructed. else if (compoRunningContext.State == ComponentRunningContext.ComponentState.Created) /// The component is created. else if (compoRunningContext.State == ComponentRunningContext.ComponentState.Started) /// The component is started. else if (compoRunningContext.State == ComponentRunningContext.ComponentState.Resumed) /// The component is resumed. else if (compoRunningContext.State == ComponentRunningContext.ComponentState.Paused) /// The component is paused else if (compoRunningContext.State == ComponentRunningContext.ComponentState.Destroyed) /// The component is destroyed. else /// State is undefined
-
Resume the running application:
C#CopycompoRunningContext.Resume();
-
Manage component information
To get the installed information and its details, and to operate on the information, follow these steps:
-
Get the information of the currently-installed component by creating an instance of the Tizen.Applications.ComponentBased.ComponentInfo class, with the ID information obtained from a component as a parameter.
To get a component’s information, the component must be installed:
C#CopyComponentInfo compoInfo = new ComponentInfo(Your Component ID);
-
Operate on the information:
-
Get the component ID and application ID:
C#Copystring componentId = compoInfo.ComponentId; string applicationId = compoInfo.ApplicationId;
-
Check the type of the component:
C#Copyif (compoInfo.ComponentType == ComponentType.Frame) /// The component is frame-component. else if (compoInfo.ComponentType == ComponentType.Service) /// The component is service-component else /// ComponentType is undefined
-
Get the label and the icon path:
C#Copystring label = compoInfo.Label; string iconPath = compoInfo.IconPath;
-
-
Call the
GetInstalledComponentsAsync()
method of the Tizen.Applications.ComponentBased.ComponentManager class, and retrieve all components and print their information:C#CopyIEnumerable<ComponentInfo> compoInfoList = await ComponentManager.GetInstalledComponentsAsync(); foreach (ComponentInfo compoInfo in compoInfoList) { Log.Debug("Tag", "componentId: " + compoInfo.ComponentId); Log.Debug("Tag", "applicationId: " + compoInfo.ApplicationId); Log.Debug("Tag", "label: " + compoInfo.Label); Log.Debug("Tag", "iconPath: " + compoInfo.IconPath); Log.Debug("Tag", "ComponentType: " + compoInfo.ComponentType.ToString()); Log.Debug("Tag", "isIconDisplayed: " + compoInfo.IsIconDisplayed.ToString()); Log.Debug("Tag", "isManagedByTaskManager: " + compoInfo.IsManagedByTaskManager.ToString()); }
Related information
- Dependencies
- Tizen 5.5 and Higher