diff --git a/PublicAPI.md b/PublicAPI.md index 4009ed25e3..4f1bd3b159 100644 --- a/PublicAPI.md +++ b/PublicAPI.md @@ -48,6 +48,8 @@ const tns = require("nativescript"); * [assetsGenerationService](#assetsgenerationservice) * [generateIcons](#generateicons) * [generateSplashScreens](#generatesplashscreens) +* [androidProcessService](#androidprocessservice) + * [getAppProcessId](#getappprocessid) ## Module projectService @@ -1125,6 +1127,29 @@ tns.assetsGenerationService.generateSplashScreens({ projectDir: "/Users/username }); ``` +## androidProcessService +The `androidProcessService` exposes methods for getting information about the applications working on Android devices. + +### getAppProcessId +The `getAppProcessId` returns the PID of the specified application. If the app is not running on device, the method will return null. + +* Definition +```TypeScript +/** + * Gets the PID of a running application. + * @param deviceIdentifier {string} The identifier of the device. + * @param appIdentifier The identifier of the application. + * @return {string} Returns the process id matching the application identifier in the device process list. + */ +getAppProcessId(deviceIdentifier: string, appIdentifier: string): Promise; +``` + +* Usage +```JavaScript +tns.androidProcessService.getAppProcessId("4df18f307d8a8f1b", "org.nativescript.demoapp") + .then(pid => console.log(`The PID is ${pid}`)) + .catch(err => console.error(`Error while checking for PID: ${err}`)); +``` ## How to add a new method to Public API diff --git a/lib/common b/lib/common index 8fc0ffbb1a..bb3edc276f 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit 8fc0ffbb1a5e23e4d4ed8c787c3070029f352d58 +Subproject commit bb3edc276f679a857ea251747834781394791c9d diff --git a/test/nativescript-cli-lib.ts b/test/nativescript-cli-lib.ts index cc40ba743c..9edc5bf7e6 100644 --- a/test/nativescript-cli-lib.ts +++ b/test/nativescript-cli-lib.ts @@ -47,7 +47,10 @@ describe("nativescript-cli-lib", () => { ], assetsGenerationService: [ "generateIcons", - "generateSplashScreens" + "generateSplashScreens", + ], + androidProcessService: [ + "getAppProcessId" ] };