未验证 提交 66671fa0 编写于 作者: O openharmony_ci 提交者: Gitee

!16641 翻译完成 16407:FAQ更新,VOD修改

Merge pull request !16641 from ester.zhou/cherry-pick-1680052802
...@@ -2,23 +2,21 @@ ...@@ -2,23 +2,21 @@
## How do I obtain the DPI of a device? ## How do I obtain the DPI of a device?
Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9 Applicable to: OpenHarmony 3.2 Beta5, stage model of API version 9
Import the **\@ohos.display** module and call the **getDefaultDisplay** API.
Example: Import the **@ohos.display** module and call the **getDefaultDisplaySync** API.
**Example**
``` ```
import display from '@ohos.display'; import display from '@ohos.display';
display.getDefaultDisplay((err, data) => { let displayClass = null;
if (err.code) { try {
console.error('Test Failed to obtain the default display object. Code: ' + JSON.stringify(err)); displayClass = display.getDefaultDisplaySync();
return; console.info('Test densityDPI:' + JSON.stringify(data.densityDPI));
} } catch (exception) {
console.info('Test Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
console.info('Test densityDPI:' + JSON.stringify(data.densityDPI)); }
});
``` ```
## How do I obtain the type of the device where the application is running? ## How do I obtain the type of the device where the application is running?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册