| ctx | Context | Yes | Current application context.For the definition of **Context** of API version 8, see [Context](js-apis-Context.md). For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md). |
| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained. |
- Example
```
```js
varwindowClass=null;
window.getTopWindow(this.context,(err,data)=>{
if(err.code){
...
...
@@ -454,7 +454,7 @@ Obtains the top window of the current application. This API uses a promise to re
| ctx | Context | Yes | Current application context.For the definition of **Context** of API version 8, see [Context](js-apis-Context.md). For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md). |
- Return value
...
...
@@ -464,7 +464,7 @@ Obtains the top window of the current application. This API uses a promise to re
- Example
```
```js
varwindowClass=null;
letpromise=window.getTopWindow(this.context);
promise.then((data)=>{
...
...
@@ -494,7 +494,7 @@ This is a system API and cannot be called by third-party applications.
- Example
```
```js
vartype='systemBarTintChange';
windowClass.on(type,(data)=>{
console.info('Succeeded in enabling the listener for systemBarTint changes. Data: '+JSON.stringify(data));
...
...
@@ -520,7 +520,7 @@ This is a system API and cannot be called by third-party applications.
- Example
```
```js
vartype='systemBarTintChange';
windowClass.off(type);
```
...
...
@@ -547,7 +547,7 @@ This is a system API and cannot be called by third-party applications.
- Example
```
```js
windowClass.hide((err,data)=>{
if(err.code){
console.error('Failed to hide the window. Cause: '+JSON.stringify(err));
...
...
@@ -575,7 +575,7 @@ This is a system API and cannot be called by third-party applications.
| FOREGROUND | 1 | The window stage is running in the foreground. |
| ACTIVE | 2 | The window stage gains focus. |
| INACTIVE | 3 | The window stage loses focus. |
| BACKGROUND | 4 | The window stage is running in the background. |
## WindowStage<sup>9+</sup>
Before calling any of the following APIs, you must use `[onWindowStageCreate()](js-apis-application-ability.md#abilityonwindowstagecreate)` to create a **WindowStage** instance.
### getMainWindow<sup>9+</sup>
getMainWindow(): Promise<Window>
Obtains the main window of this window stage. This API uses a promise to return the result.