From 96a21d71f54e8c625cd36575033443b6f63acd1d Mon Sep 17 00:00:00 2001 From: "ester.zhou" Date: Wed, 29 Mar 2023 09:10:27 +0800 Subject: [PATCH] Update doc (16412) Signed-off-by: ester.zhou --- .../faqs/faqs-device-management.md | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/en/application-dev/faqs/faqs-device-management.md b/en/application-dev/faqs/faqs-device-management.md index dd836eb11a..ea71edd6c9 100644 --- a/en/application-dev/faqs/faqs-device-management.md +++ b/en/application-dev/faqs/faqs-device-management.md @@ -2,23 +2,21 @@ ## How do I obtain the DPI of a device? -Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9 - -Import the **\@ohos.display** module and call the **getDefaultDisplay** API. +Applicable to: OpenHarmony 3.2 Beta5, stage model of API version 9 -Example: +Import the **@ohos.display** module and call the **getDefaultDisplaySync** API. +**Example** ``` import display from '@ohos.display'; -display.getDefaultDisplay((err, data) => { - if (err.code) { - console.error('Test Failed to obtain the default display object. Code: ' + JSON.stringify(err)); - return; - } - console.info('Test Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); - console.info('Test densityDPI:' + JSON.stringify(data.densityDPI)); -}); +let displayClass = null; +try { + displayClass = display.getDefaultDisplaySync(); + console.info('Test densityDPI:' + JSON.stringify(data.densityDPI)); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); +} ``` ## How do I obtain the type of the device where the application is running? -- GitLab