From d0dbfc00638c4f9c3790f9a624ccd357673c6222 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 26 Sep 2017 19:16:06 +0900 Subject: [PATCH] Add guide document for PackageManager of dotnet PS3: Reviewed Change-Id: If82339af3ae173f66fd27ce2c8802cea4b81d099 Signed-off-by: Sangyoon Jang --- .../html/dotnet/package_manager_cs.htm | 174 +++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 org.tizen.guides/html/dotnet/package_manager_cs.htm diff --git a/org.tizen.guides/html/dotnet/package_manager_cs.htm b/org.tizen.guides/html/dotnet/package_manager_cs.htm new file mode 100644 index 0000000..87bb7ce --- /dev/null +++ b/org.tizen.guides/html/dotnet/package_manager_cs.htm @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + Package Manager + + + + + +
+

Package Manager

+ +

The package manager is used to retrieve detailed information on the installed packages on the device. This information includes the package name, label, path to the icon image, version, type, and installed storage.

+ +

The main features of the Tizen.Applications.PackageManager class include:

+ + +

Prerequisites

+ +

To enable your application to use the package manager functionality:

+
    +
  1. +

    To use the Tizen.Applications.PackageManager class, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

    +
    +<privileges>
    +   <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
    +</privileges>
    +
    +
  2. +
  3. To use the methods and properties of the Tizen.Applications.PackageManager class, include the Tizen.Applications namespace in your application:

    +
    +using Tizen.Applications;
    +
  4. +
+ +

Retrieving All Package Information

+ +

To retrieve all package information for installed packages:

+ +
    +
  1. Retrieve all package information with the GetPackages() method of the Tizen.Applications.PackageManager class: + +
    +IEnumerable<Package> packageList = PackageManager.GetPackages();
    +
  2. +
  3. Iterate through the returned list to access information about each Tizen.Applications.Package object: +
    +foreach (Package package in packageList)
    +{
    +    Log.Debug(LogTag, "pkgid: " + package.Id);
    +    Log.Debug(LogTag, "label: " + package.Label);
    +    Log.Debug(LogTag, "icon: " + package.IconPath);
    +    Log.Debug(LogTag, "version: " + package.Version);
    +    Log.Debug(LogTag, "type: " + package.PackageType);
    +    Log.Debug(LogTag, "storage: " + package.InstalledStorageType);
    +    Log.Debug(LogTag, "system: " + package.IsSystemPackage);
    +    Log.Debug(LogTag, "removable: " + package.IsRemovable);
    +    Log.Debug(LogTag, "preload: " + package.IsPreloaded);
    +}
    +
+ +

Retrieving Specific Package Information

+ +

To get specific package information:

+
    +
  1. Retrieve information for a specific package with the GetPackage() method of the Tizen.Applications.PackageManager class: + +
    +Package package = PackageManager.GetPackage("org.tizen.helloworld");
    +
    +
  2. +
  3. Use the Tizen.Applications.Package object returned by the GetPackage() method to access various package details: + +
    +/// Use package information
    +Log.Debug(LogTag, "pkgid: " + package.Id);
    +Log.Debug(LogTag, "label: " + package.Label);
    +Log.Debug(LogTag, "icon: " + package.IconPath);
    +Log.Debug(LogTag, "version: " + package.Version);
    +Log.Debug(LogTag, "type: " + package.PackageType);
    +Log.Debug(LogTag, "storage: " + package.InstalledStorageType);
    +Log.Debug(LogTag, "system: " + package.IsSystemPackage);
    +Log.Debug(LogTag, "removable: " + package.IsRemovable);
    +Log.Debug(LogTag, "preload: " + package.IsPreloaded);
    +
    +
  4. +
+ +

Monitoring Package Events

+ +

To detect package-related events, such as installation, uninstallation, and updates:

+
    +
  1. Register event handlers for various events of the Tizen.Applications.PackageManager class. +

    The following example registers event handlers for package installation, uninstallation, and update events:

    +
    +PackageManager.InstallProgressChanged += new System.EventHandler<PackageManagerEventArgs>(InstallEventHandler);
    +PackageManager.UninstallProgressChanged += new System.EventHandler<PackageManagerEventArgs>(UninstallEventHandler);
    +PackageManager.UpdateProgressChanged += new System.EventHandler<PackageManagerEventArgs>(UpdateEventHandler);
    +
    +
  2. +
  3. Define the event handlers. When the related event occurs, the event handler is triggered and you can get the event details from the Tizen.Applications.PackageManagerEventArgs instance. +

    The following example implements the installation event handler:

    +
    +void InstallEventHandler(object sender, PackageManagerEventArgs args)
    +{
    +    Log.Debug(LogTag, "pkgId: " + args.PackageId);
    +    Log.Debug(LogTag, "pkgType:" + args.PackageType);
    +    Log.Debug(LogTag, "progress:" + args.Progress);
    +    Log.Debug(LogTag, "eventState:" + args.State);
    +}
    +
    +
  4. +
+ + + +
+ +Go to top + + + + + + + -- 2.7.4