Application Manager
The application manager provides information about installed and running applications. It provides functions for obtaining the application name and absolute path to share files among all applications.
The main features of the Tizen.Applications.ApplicationManager
class include the following:
-
Managing the application running context
For running applications, you can retrieve the application running context and operate on it. You can manage the application running context with the
Tizen.Applications.ApplicationManager
class. -
Getting information on filtered applications
For installed (but not necessarily running) applications, you can retrieve information with the Tizen.Applications.ApplicationInfo class. You can also retrieve information through a filter with the Tizen.Applications.ApplicationInfoFilter class.
-
Getting information on the current application
For current applications, you can retrieve information using the Tizen.Applications class. You can use the retrieved information to manage the current application.
Iterator methods are used to travel through a list of applications. The GetRunningApplicationsAsync()
method of the Tizen.Applications.ApplicationManager
class is used for running applications and the GetInstalledApplicationsAsync()
method is used for installed applications.
Prerequisites
To enable your application to use the application management functionality, follow these steps:
-
To use the methods and properties of the Tizen.Applications.ApplicationManager, Tizen.Applications.ApplicationRunningContext, and Tizen.Applications.ApplicationInfo classes, include the Tizen.Applications namespace in your application:
C#Copyusing Tizen.Applications;
-
To use the
Resume()
method of theTizen.Applications.ApplicationRunningContext
class, the application has to request permission by adding the following privilege to thetizen-manifest.xml
file:XMLCopy<privileges> <privilege>http://tizen.org/privilege/appmanager.launch</privilege> </privileges>
Manage application running context
To manage the context of the currently running application, follow these steps:
-
Get the context of the currently running application. To get the context, create an instance of the Tizen.Applications.ApplicationRunningContext class, with the ID of the application from which the context is being obtained as a parameter.
If you do not have the application ID, you can retrieve it as:
C#Copystring applicationId = ApplicationManager.GetAppId(Your PID);
When an application is not running, it is impossible to get its context:
C#CopyApplicationRunningContext appRunningContext = new ApplicationRunningContext(Your App ID);
-
Operate on the application context:
-
Get the application ID, package ID, and process ID from the context:
C#Copystring applicationId = appRunningContext.ApplicationId; string packageId = appRunningContext.PackageId; int processId = appRunningContext.ProcessId;
-
Check the state of the application:
C#Copyif (appRunningContext.State == ApplicationRunningContext.AppState.Foreground) /// UI application is running in the foreground else if (appRunningContext.State == ApplicationRunningContext.AppState.Background) /// UI application is running in the background else if (appRunningContext.State == ApplicationRunningContext.AppState.Service) /// Service application is running else if (appRunningContext.State == ApplicationRunningContext.AppState.Terminated) /// Application is terminated else /// State is undefined if (appRunningContext.IsTerminated) { /// Application is not running now }
-
Resume the running application:
C#CopyappRunningContext.Resume();
-
Terminate the background application:
C#CopyappRunningContext.TerminateBackgroundApplication();
-
Get information on filtered applications
To get information on filtered applications, follow these steps:
-
Create the filter as an instance of the Tizen.Applications.ApplicationInfoFilter class:
C#CopyApplicationInfoFilter appInfoFilter = new ApplicationInfoFilter();
-
Add filter rules:
C#CopyappInfoFilter.Filter.Add(ApplicationInfoFilter.Keys.Type, "dotnet");
-
Call the
GetInstalledApplicationsAsync()
method of the Tizen.Applications.ApplicationManager class and retrieve all filtered applications and print their information:C#CopyIEnumerable<ApplicationInfo> appInfoList = await ApplicationManager.GetInstalledApplicationsAsync(appinfoFilter); foreach (ApplicationInfo appInfo in appInfoList) { Log.Debug("Tag", "applicationId: " + appInfo.ApplicationId); Log.Debug("Tag", "packageId: " + appInfo.PackageId); Log.Debug("Tag", "label: " + appInfo.Label); Log.Debug("Tag", "executablePath: " + appInfo.ExecutablePath); Log.Debug("Tag", "iconPath: " + appInfo.IconPath); Log.Debug("Tag", "applicationType: " + appInfo.ApplicationType); Log.Debug("Tag", "isNoDisplay: " + appInfo.IsNoDisplay.ToString()); Log.Debug("Tag", "isOnBoot: " + appInfo.IsOnBoot.ToString()); Log.Debug("Tag", "isPreload: " + appInfo.IsPreload.ToString()); Log.Debug("Tag", "sharedResourcePath: " + appInfo.SharedResourcePath); }
Get information on current application
To get information on the current application, follow these steps:
-
Call the
Current
property of the Tizen.Applications class:C#CopyApplication application = Application.Current;
-
Operate on the application information:
-
Get the application directory information:
C#CopyDirectoryInfo directory = application.DirectoryInfo;
-
Get the application name:
C#Copystring name = application.Name;
-
Get the application version:
C#Copystring version = application.Version;
-
Related information
- Dependencies
- Tizen 4.0 and Higher