| condition | string | Yes | Matching condition of a media event. For details, see [Syntax of Media Query Conditions](../../ui/ui-ts-layout-mediaquery.md#syntax-of-media-query-conditions).|
- Example
**Return value**
| Type | Description |
| ------------------ | ---------------------- |
| MediaQueryListener | Listening handle to a media event, which is used to register or deregister the listening callback.|
**Example**
```js
letlistener=mediaquery.matchMediaSync('(orientation: landscape)');// Listen for landscape events.
listener=mediaquery.matchMediaSync('(orientation: landscape)');// Listen for landscape events.
Unregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change.
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | boolean | Yes| Must enter the string **change**.|
| callback | Callback<MediaQueryResult> | No| Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered.|
Deregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change.
| type | boolean | Yes | Must enter the string **change**. |
| callback | Callback<MediaQueryResult> | No | Callback to be deregistered. If the default value is used, all callbacks of the handle are deregistered.|
- Example
**Example**
```js
importmediaqueryfrom'@ohos.mediaquery'
letlistener=mediaquery.matchMediaSync('(orientation: landscape)');// Listen for landscape events.
listener=mediaquery.matchMediaSync('(orientation: landscape)');// Listen for landscape events.
functiononPortrait(mediaQueryResult){
if(mediaQueryResult.matches){
// do something here
...
...
@@ -91,7 +100,7 @@ Unregisters a callback with the corresponding query condition by using the handl
}
}
listener.on('change',onPortrait)// Register a callback.
listener.off('change',onPortrait)// Unregister a callback.
listener.off('change',onPortrait)// Deregister a callback.
```
...
...
@@ -100,10 +109,10 @@ Unregisters a callback with the corresponding query condition by using the handl