Class ApplicationManager
Definition
- Namespace:
- Tizen.Applications
- Assembly:
- Tizen.Applications.Common.dll
This class has the methods and events of the ApplicationManager.
public static class ApplicationManager
- Inheritance
-
objectApplicationManager
Methods
View SourceGetAllRunningApplicationsAsync()
Asynchronously retrieves the information about all currently running applications, including subapps.
Declaration
public static Task<IEnumerable<ApplicationRunningContext>> GetAllRunningApplicationsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResult><System.Collections.Generic.IEnumerable<T><ApplicationRunningContext>> | An enumerable list containing details about the running applications. |
Remarks
This method provides access to the current state of all active applications on the device, allowing you to gather information such as their IDs, types, and states. By utilizing this functionality, developers can gain insights into the overall system activity and make informed decisions based on the available data.
Examples
Here is an example that demonstrates how to utilize the GetAllRunningApplicationsAsync method in order to obtain information about the currently running applications:
// Initiate the call to get all running applications
IEnumerable<ApplicationRunningContext> runningApps = await GetAllRunningApplicationsAsync();
// Iterate through the obtained list of running apps
foreach (var app in runningApps)
{
Console.WriteLine($"Id: {app.ApplicationId}");
}
View Source
GetAppId(int)
Retrieves the application ID based on the specified process ID.
Declaration
public static string GetAppId(int processId)
Parameters
Type | Name | Description |
---|---|---|
int | processId | The process ID of the target application. |
Returns
Type | Description |
---|---|
string | The application ID associated with the given process ID. |
Remarks
By providing the process ID as input, this function enables you to obtain the corresponding application ID. It ensures that the correct application is identified even if multiple applications are running simultaneously.
Examples
The following code snippet demonstrates how to retrieve the application ID by calling the GetAppId() function:
int processId = 12345; // Replace with actual process ID
string appId = GetAppId(processId);
Console.WriteLine($"Application ID: {appId}");
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If the argument passed in is not valid. |
GetInstalledApplication(string)
Retrieves the information of the specified application by its application ID.
Declaration
public static ApplicationInfo GetInstalledApplication(string applicationId)
Parameters
Type | Name | Description |
---|---|---|
string | applicationId | The ID of the target application. |
Returns
Type | Description |
---|---|
ApplicationInfo | An object containing detailed information about the requested application. |
Remarks
This function enables you to obtain specific information about an application based on its application ID. It returns an object that contains various attributes such as the package name, version, icon URL, etc., which are associated with the identified application. If the specified application does not exist in the system, an error message will be thrown indicating that the requested application could not be found.
Examples
The following code snippet demonstrates how to retrieve the details of an application with the ID "org.example.app":
// Retrieve the application details
ApplicationInfo appInfo = ApplicationManager.GetInstalledApplication("org.example.app");
// Print the package ID of the retrieved application
Console.WriteLine($"Package ID: {appInfo.PackageId}");
View Source
GetInstalledApplicationsAsync()
Asynchronously retrieves information about the installed applications.
Declaration
public static Task<IEnumerable<ApplicationInfo>> GetInstalledApplicationsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResult><System.Collections.Generic.IEnumerable<T><ApplicationInfo>> | An asynchronous task that returns a list containing information about the installed applications. |
Remarks
By calling this method, you can retrieve details about all the applications currently installed on the device. The returned list contains ApplicationInfo objects, which provide various properties such as package ID, version, and icon.
Examples
To get the information of the installed applications, you can call the following code snippet:
var listApp = await ApplicationManager.GetInstalledApplicationsAsync();
Assert.IsNotEmpty(_listApp, "The list of installed app should not be empty.");
foreach (ApplicationInfo instapp in _listApp)
{
Console.WriteLine(instapp.ApplicationId);
}
View Source
GetInstalledApplicationsAsync(ApplicationInfoFilter)
Retrieves the information about installed applications that match the specified filter criteria in an asynchronous manner.
Declaration
public static Task<IEnumerable<ApplicationInfo>> GetInstalledApplicationsAsync(ApplicationInfoFilter filter)
Parameters
Type | Name | Description |
---|---|---|
ApplicationInfoFilter | filter | An ApplicationInfoFilter containing the desired filter criteria. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResult><System.Collections.Generic.IEnumerable<T><ApplicationInfo>> | An IEnumerable<ApplicationInfo> containing the information of the installed applications that match the specified filter. |
Remarks
By specifying the desired filter criteria through the filter
argument, you can retrieve only those applications that meet these conditions. The returned result will contain a list of ApplicationInfo objects representing the matched applications.
Examples
The following code snippet demonstrates how to obtain the information of all installed applications:
var filter = new ApplicationInfoFilter();
filter.Filter.Add(ApplicationInfoFilter.Keys.Id, "org.exmaple.hello");
var apps = await GetInstalledApplicationsAsync(filter);
foreach (var app in apps)
{
Console.WriteLine(app.ApplicationId);
}
View Source
GetInstalledApplicationsAsync(ApplicationInfoMetadataFilter)
Asynchronously retrieves the information about installed applications filtered by the specified criteria in the form of ApplicationInfoMetadataFilter.
Declaration
public static Task<IEnumerable<ApplicationInfo>> GetInstalledApplicationsAsync(ApplicationInfoMetadataFilter filter)
Parameters
Type | Name | Description |
---|---|---|
ApplicationInfoMetadataFilter | filter | A dictionary of key-value pairs used to define the specific filtering criteria. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResult><System.Collections.Generic.IEnumerable<T><ApplicationInfo>> | An enumerable collection of ApplicationInfo objects representing the installed applications that meet the specified filtering criteria. |
Remarks
By providing the filter argument, you can specify various conditions such as package names, types, visibility status, etc., which will help narrow down the search results to only those that match the desired criteria. The returned result is a list of ApplicationInfo objects containing detailed information about each matched application.
Examples
To retrieve all visible applications:
var filter = new ApplicationInfoMetadataFilter();
filter.Filter.Add("http://tizen.org/metadata/test-id", "org.exmaple.hello");
var apps = await GetInstalledApplicationsAsync(filter);
foreach (var app in apps)
{
Console.WriteLine(app.ApplicationId);
}
View Source
GetRunningApplicationsAsync()
Asynchronously retrieves the information about currently running applications.
Declaration
public static Task<IEnumerable<ApplicationRunningContext>> GetRunningApplicationsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResult><System.Collections.Generic.IEnumerable<T><ApplicationRunningContext>> | An enumerable list containing details about the running applications. |
Remarks
This method provides an efficient way to gather information about all the active apps on the device without blocking the current thread. It returns a task which can be awaited in order to obtain the desired result.
Examples
Here's an example demonstrating how to retrieve the running applications and display their IDs:
await ApplicationManager.GetRunningApplicationsAsync().ContinueWith((task) => {
foreach (var app in task.Result) {
Console.WriteLine(app.ApplicationId);
}
});
View Source
IsRunning(string)
Determines whether the specified application is currently running.
Declaration
public static bool IsRunning(string applicationId)
Parameters
Type | Name | Description |
---|---|---|
string | applicationId | The unique identifier of the application to check. |
Returns
Type | Description |
---|---|
bool | True if the application identified by the given ID is currently running, otherwise False. |
Examples
The following code snippet demonstrates how to determine if a specific application is currently running:
string applicationId = "org.example.app";
if (ApplicationManager.IsRunning(applicationId))
{
Console.WriteLine("The application with ID '{0}' is currently running.", applicationId);
}
else
{
Console.WriteLine("The application with ID '{0}' is not currently running.", applicationId);
}
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when the provided argument is invalid or missing. |
TerminateBackgroundApplication(ApplicationRunningContext)
Terminates the application if it is running on background.
Declaration
public static void TerminateBackgroundApplication(ApplicationRunningContext app)
Parameters
Type | Name | Description |
---|---|---|
ApplicationRunningContext | app | ApplicationRunningContext object |
Remarks
This function returns after it just sends a request for terminating a background application. Platform will decide if the target application could be terminated or not according to the state of the target application.
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when failed of invalid argument. |
System.UnauthorizedAccessException | Thrown when failed because of permission denied. |
System.InvalidOperationException | Thrown when failed because of system error. |
Events
View SourceApplicationDisabled
Occurs whenever the installed application is disabled.
Declaration
public static event EventHandler<ApplicationDisabledEventArgs> ApplicationDisabled
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><ApplicationDisabledEventArgs> |
Remarks
This event is raised whenever the user disables an installed application through the Settings menu. The event handler receives an argument of type ApplicationDisabledEventArgs which contains information about the disabled application.
ApplicationEnabled
Occurs whenever the installed application is enabled.
Declaration
public static event EventHandler<ApplicationEnabledEventArgs> ApplicationEnabled
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><ApplicationEnabledEventArgs> |
Remarks
This event is raised whenever the installed application is enabled. It provides information about the application that was enabled through the arguments passed in the event handler.
ApplicationLaunched
Occurs whenever the installed applications get launched.
Declaration
public static event EventHandler<ApplicationLaunchedEventArgs> ApplicationLaunched
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><ApplicationLaunchedEventArgs> |
Remarks
This event provides information about the application that was just launched, including its package ID, version, and other details. It is useful for tracking and monitoring application launches in order to gather statistics or perform certain actions based on specific conditions.
ApplicationTerminated
Occurs whenever the installed applications get terminated.
Declaration
public static event EventHandler<ApplicationTerminatedEventArgs> ApplicationTerminated
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><ApplicationTerminatedEventArgs> |
Remarks
This event is raised whenever any application gets terminated on the device. It provides information about the terminated application through the arguments passed in the event handler.