Skip to content

Commit

Permalink
feat(API): Expose androidProcessService - getAppProcessId
Browse files Browse the repository at this point in the history
Expose the `getAppProcessId` method from `androidProcessService`, so it can be called when using CLI as a library.
  • Loading branch information
rosen-vladimirov committed Apr 22, 2018
1 parent 2e866b2 commit 6bb40de
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
25 changes: 25 additions & 0 deletions PublicAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const tns = require("nativescript");
* [assetsGenerationService](#assetsgenerationservice)
* [generateIcons](#generateicons)
* [generateSplashScreens](#generatesplashscreens)
* [androidProcessService](#androidprocessservice)
* [getAppProcessId](#getappprocessid)

## Module projectService

Expand Down Expand Up @@ -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<string>;
```
* 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
Expand Down
2 changes: 1 addition & 1 deletion lib/common
5 changes: 4 additions & 1 deletion test/nativescript-cli-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ describe("nativescript-cli-lib", () => {
],
assetsGenerationService: [
"generateIcons",
"generateSplashScreens"
"generateSplashScreens",
],
androidProcessService: [
"getAppProcessId"
]
};

Expand Down

0 comments on commit 6bb40de

Please sign in to comment.