App Management

GoToApp

Open specified app.

public static void GoToApp(string packageName)

Parameter

Description

packageName

App package name

CloseApp

Kill the process of the specified app.

public static void CloseApp(string packageName)

Parameter

Description

packageName

App package name

StartAppWithExtra

Start activity with extras, the keys should correspond with values.

public static bool StartAppWithExtra(string packageName, string className, string[] key, string[] value)

packageName

App package name

className

full class name

key

array of all keys

value

array of all values

StartAppWithAction

Start activity by action.

public static bool StartAppWithAction(string action)

Parameter

Description

action

full string of intent action

InstallApk

Install apk silently.

public static void InstallApk(string apkPath,
                              OnPackageInstallSuccessHandler successCallback = null,
                              OnPackageInstallErrorHandler errorHandler = null)

Parameter

Description

apkPath

Apk file path.

successCallback

Callback when install successfully. User can use this method to get install successful event. The callback is called in the thread of user called InstallApk if calling thread has an Android Looper, otherwise called in the main thread.

errorHandler

Callback when install failed.

Prototype for OnPackageInstallSuccessHandler

public delegate void OnPackageInstallSuccessHandler(string apkPath, string packageName);

Prototype for OnPackageInstallErrorHandler

public delegate void OnPackageInstallErrorHandler(string apkPath, int errorCode);

UninstallApk

Uninstall specified app.

public static void UninstallApk(string packageName,
                                OnPackageUninstallSuccessHandler successCallback = null,
                                OnPackageUninstallErrorHandler errorCallback = null)

Parameter

Description

packageName

App package name.

successCallback

Callback when uninstall successfully.

errorCallback

Callback when uninstall failed.

Prototype for OnPackageUninstallSuccessHandler

public delegate void OnPackageUninstallSuccessHandler(string packageName);

Prototype for OnPackageUninstallErrorHandler

public delegate void OnPackageUninstallErrorHandler(string packageName, int errorCode);

GetInstalledAppList

Get installed app package name list, include system apps and un-system apps.

public static string[] GetInstalledAppList(bool onlyLauncher = true)

Parameter

Description

onlyLauncher

only apps have launcher

GetAppNameByPackageName

Get app name by package name.

public static string GetAppNameByPkgname(string pkgname)

Parameter

Description

packageName

App package name

GetAppIconByPackageName

Get app icon byte array by package name.

public static byte[] GetAppIconByPkgname(string pkgname)

Parameter

Description

packageName

App package name.

ShowControllerBindPage

Intent to bind controller page in launcher.

public static void ShowControllerBindPage()

Last updated