Skip to content

feat(API): Expose androidProcessService - getAppProcessId #3535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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