提交 decd70ee 编写于 作者: L lovechinamo

Signed-off-by: lovechinamo <wangdongqi2@huawei.com>

 Changes to be committed:
上级 476489d3
...@@ -47,7 +47,7 @@ getInputMethodController(): InputMethodController ...@@ -47,7 +47,7 @@ getInputMethodController(): InputMethodController
| [InputMethodController](#InputMethodController) | 回调返回当前客户端实例。 | | [InputMethodController](#InputMethodController) | 回调返回当前客户端实例。 |
- 示例 - 示例
``` ```js
var InputMethodController = inputMethod.getInputMethodController(); var InputMethodController = inputMethod.getInputMethodController();
``` ```
## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a> ## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a>
...@@ -66,7 +66,7 @@ getInputMethodSetting(): InputMethodSetting ...@@ -66,7 +66,7 @@ getInputMethodSetting(): InputMethodSetting
- 示例 - 示例
``` ```js
var InputMethodSetting = inputMethod.getInputMethodSetting(); var InputMethodSetting = inputMethod.getInputMethodSetting();
``` ```
...@@ -90,7 +90,7 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -90,7 +90,7 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void
- 示例 - 示例
``` ```js
InputMethodController.stopInput((error)=>{ InputMethodController.stopInput((error)=>{
console.info('stopInput'); console.info('stopInput');
}); });
...@@ -113,7 +113,7 @@ stopInput(): Promise&lt;boolean&gt; ...@@ -113,7 +113,7 @@ stopInput(): Promise&lt;boolean&gt;
- 示例 - 示例
``` ```js
var isSuccess = InputMethodController.stopInput(); var isSuccess = InputMethodController.stopInput();
console.info('stopInput isSuccess = ' + isSuccess); console.info('stopInput isSuccess = ' + isSuccess);
``` ```
...@@ -136,7 +136,7 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;) ...@@ -136,7 +136,7 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;)
| callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 | | callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 |
- 示例 - 示例
``` ```js
InputMethodSetting.listInputMethod((properties)=>{ InputMethodSetting.listInputMethod((properties)=>{
for (var i = 0;i < properties.length; i++) { for (var i = 0;i < properties.length; i++) {
var property = properties[i]; var property = properties[i];
...@@ -159,7 +159,7 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt; ...@@ -159,7 +159,7 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
| Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | 返回已安装输入法列表。 | | Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | 返回已安装输入法列表。 |
- 示例 - 示例
``` ```js
var properties = InputMethodSetting.listInputMethod(); var properties = InputMethodSetting.listInputMethod();
for (var i = 0;i < properties.length; i++) { for (var i = 0;i < properties.length; i++) {
var property = properties[i]; var property = properties[i];
...@@ -182,7 +182,7 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void ...@@ -182,7 +182,7 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
- 示例 - 示例
``` ```js
InputMethodSetting.displayOptionalInputMethod(()=>{ InputMethodSetting.displayOptionalInputMethod(()=>{
console.info('displayOptionalInputMethod is called'); console.info('displayOptionalInputMethod is called');
}); });
...@@ -203,6 +203,6 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void ...@@ -203,6 +203,6 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
| Promise&lt;void&gt; | 回调函数。 | | Promise&lt;void&gt; | 回调函数。 |
- 示例 - 示例
``` ```js
InputMethodSetting.displayOptionalInputMethod(); InputMethodSetting.displayOptionalInputMethod();
``` ```
\ No newline at end of file
...@@ -60,7 +60,7 @@ getInputMethodEngine(): InputMethodEngine ...@@ -60,7 +60,7 @@ getInputMethodEngine(): InputMethodEngine
- 示例 - 示例
``` ```js
var InputMethodEngine = inputMethodEngine.getInputMethodEngine(); var InputMethodEngine = inputMethodEngine.getInputMethodEngine();
``` ```
...@@ -80,7 +80,7 @@ createKeyboardDelegate(): KeyboardDelegate ...@@ -80,7 +80,7 @@ createKeyboardDelegate(): KeyboardDelegate
- 示例 - 示例
``` ```js
var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
``` ```
...@@ -105,7 +105,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli ...@@ -105,7 +105,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli
- 示例: - 示例:
``` ```js
InputMethodEngine.on('inputStart', (kbController, textInputClient) => { InputMethodEngine.on('inputStart', (kbController, textInputClient) => {
KeyboardController = kbController; KeyboardController = kbController;
TextInputClient = textInputClient; TextInputClient = textInputClient;
...@@ -131,7 +131,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC ...@@ -131,7 +131,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC
- 示例: - 示例:
``` ```js
InputMethodEngine.off('inputStart'); InputMethodEngine.off('inputStart');
``` ```
...@@ -152,7 +152,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void ...@@ -152,7 +152,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
- 示例: - 示例:
``` ```js
InputMethodEngine.on('keyboardShow', (err) => { InputMethodEngine.on('keyboardShow', (err) => {
console.info('keyboardShow'); console.info('keyboardShow');
}); });
...@@ -175,7 +175,7 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void ...@@ -175,7 +175,7 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
- 示例: - 示例:
``` ```js
InputMethodEngine.off('keyboardShow'); InputMethodEngine.off('keyboardShow');
``` ```
...@@ -203,7 +203,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void ...@@ -203,7 +203,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
- 示例: - 示例:
``` ```js
KeyboardDelegate.on('keyDown', (event) => { KeyboardDelegate.on('keyDown', (event) => {
console.info('keyDown'); console.info('keyDown');
}); });
...@@ -226,7 +226,7 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void ...@@ -226,7 +226,7 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
- 示例: - 示例:
``` ```js
KeyboardDelegate.off('keyDown'); KeyboardDelegate.off('keyDown');
``` ```
...@@ -249,7 +249,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) = ...@@ -249,7 +249,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) =
- 示例: - 示例:
``` ```js
KeyboardDelegate.on('cursorContextChange', (x, y, height) => { KeyboardDelegate.on('cursorContextChange', (x, y, height) => {
console.info('cursorContextChange'); console.info('cursorContextChange');
}); });
...@@ -273,7 +273,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number) ...@@ -273,7 +273,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number)
- 示例: - 示例:
``` ```js
KeyboardDelegate.off('cursorContextChange'); KeyboardDelegate.off('cursorContextChange');
``` ```
### on('selectionChange') ### on('selectionChange')
...@@ -293,7 +293,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi ...@@ -293,7 +293,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
- 示例: - 示例:
``` ```js
KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.info('selectionChange'); console.info('selectionChange');
}); });
...@@ -316,7 +316,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe ...@@ -316,7 +316,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe
- 示例: - 示例:
``` ```js
KeyboardDelegate.off('selectionChange'); KeyboardDelegate.off('selectionChange');
``` ```
...@@ -338,7 +338,7 @@ on(type: 'textChange', callback: (text: string) => void): void ...@@ -338,7 +338,7 @@ on(type: 'textChange', callback: (text: string) => void): void
- 示例: - 示例:
``` ```js
KeyboardDelegate.on('textChange', (text) => { KeyboardDelegate.on('textChange', (text) => {
console.info('textChange'); console.info('textChange');
}); });
...@@ -361,7 +361,7 @@ off(type: 'textChange', callback?: (text: string) => void): void ...@@ -361,7 +361,7 @@ off(type: 'textChange', callback?: (text: string) => void): void
- 示例: - 示例:
``` ```js
KeyboardDelegate.off('textChange'); KeyboardDelegate.off('textChange');
``` ```
...@@ -386,7 +386,7 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -386,7 +386,7 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void
- 示例 - 示例
``` ```js
KeyboardController.hideKeyboard(()=>{ KeyboardController.hideKeyboard(()=>{
}); });
``` ```
...@@ -408,7 +408,7 @@ hideKeyboard(): Promise&lt;void&gt; ...@@ -408,7 +408,7 @@ hideKeyboard(): Promise&lt;void&gt;
- 示例 - 示例
``` ```js
KeyboardController.hideKeyboard(); KeyboardController.hideKeyboard();
``` ```
...@@ -432,7 +432,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -432,7 +432,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
| callback | AsyncCallback&lt;string&gt; | 是 | 返回文本。 | | callback | AsyncCallback&lt;string&gt; | 是 | 返回文本。 |
- 示例 - 示例
``` ```js
TextInputClient.getForward(5,(text) =>{ TextInputClient.getForward(5,(text) =>{
console.info("text = " + text); console.info("text = " + text);
}); });
...@@ -458,7 +458,7 @@ getForward(length:number): Promise&lt;string&gt; ...@@ -458,7 +458,7 @@ getForward(length:number): Promise&lt;string&gt;
| Promise&lt;string&gt; | 返回文本。 | | Promise&lt;string&gt; | 返回文本。 |
- 示例 - 示例
``` ```js
var text = TextInputClient.getForward(5); var text = TextInputClient.getForward(5);
console.info("text = " + text); console.info("text = " + text);
``` ```
...@@ -479,7 +479,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -479,7 +479,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
| callback | AsyncCallback&lt;string&gt; | 是 | 返回文本。 | | callback | AsyncCallback&lt;string&gt; | 是 | 返回文本。 |
- 示例 - 示例
``` ```js
TextInputClient.getBackward(5,(text)=>{ TextInputClient.getBackward(5,(text)=>{
console.info("text = " + text); console.info("text = " + text);
}); });
...@@ -505,7 +505,7 @@ getBackward(length:number): Promise&lt;string&gt; ...@@ -505,7 +505,7 @@ getBackward(length:number): Promise&lt;string&gt;
| Promise&lt;string&gt; | 返回文本。 | | Promise&lt;string&gt; | 返回文本。 |
- 示例 - 示例
``` ```js
var text = TextInputClient.getBackward(5); var text = TextInputClient.getBackward(5);
console.info("text = " + text); console.info("text = " + text);
``` ```
...@@ -526,7 +526,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -526,7 +526,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
| callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 |
- 示例 - 示例
``` ```js
TextInputClient.deleteForward(5,(isSuccess)=>{ TextInputClient.deleteForward(5,(isSuccess)=>{
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
}); });
...@@ -551,7 +551,7 @@ deleteForward(length:number): Promise&lt;boolean&gt; ...@@ -551,7 +551,7 @@ deleteForward(length:number): Promise&lt;boolean&gt;
| Promise&lt;boolean&gt; | 操作成功与否。 | | Promise&lt;boolean&gt; | 操作成功与否。 |
- 示例 - 示例
``` ```js
var isSuccess = TextInputClient.deleteForward(5); var isSuccess = TextInputClient.deleteForward(5);
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
``` ```
...@@ -572,7 +572,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -572,7 +572,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
| callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 |
- 示例 - 示例
``` ```js
TextInputClient.deleteBackward(5, (isSuccess)=>{ TextInputClient.deleteBackward(5, (isSuccess)=>{
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
}); });
...@@ -598,7 +598,7 @@ deleteBackward(length:number): Promise&lt;boolean&gt; ...@@ -598,7 +598,7 @@ deleteBackward(length:number): Promise&lt;boolean&gt;
- 示例 - 示例
``` ```js
var isSuccess = TextInputClient.deleteBackward(5); var isSuccess = TextInputClient.deleteBackward(5);
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
``` ```
...@@ -618,7 +618,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -618,7 +618,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
| callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 |
- 示例 - 示例
``` ```js
TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{ TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
}); });
...@@ -644,7 +644,7 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt; ...@@ -644,7 +644,7 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt;
- 示例 - 示例
``` ```js
var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT); var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT);
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
``` ```
...@@ -665,7 +665,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -665,7 +665,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
| callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 操作成功与否。 |
- 示例 - 示例
``` ```js
TextInputClient.insertText("test", (isSuccess)=>{ TextInputClient.insertText("test", (isSuccess)=>{
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
}); });
...@@ -691,7 +691,7 @@ insertText(text:string): Promise&lt;boolean&gt; ...@@ -691,7 +691,7 @@ insertText(text:string): Promise&lt;boolean&gt;
- 示例 - 示例
``` ```js
var isSuccess = TextInputClient.insertText("test"); var isSuccess = TextInputClient.insertText("test");
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
``` ```
...@@ -710,7 +710,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void ...@@ -710,7 +710,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
| callback | AsyncCallback&lt;[EditorAttribute](#EditorAttribute)&gt; | 是 | 编辑框属性值。 | | callback | AsyncCallback&lt;[EditorAttribute](#EditorAttribute)&gt; | 是 | 编辑框属性值。 |
- 示例 - 示例
``` ```js
TextInputClient.getEditorAttribute((EditorAttribute)=>{ TextInputClient.getEditorAttribute((EditorAttribute)=>{
}); });
``` ```
...@@ -729,7 +729,7 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt; ...@@ -729,7 +729,7 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
| Promise&lt;[EditorAttribute](#EditorAttribute)&gt; | 返回编辑框属性值。 | | Promise&lt;[EditorAttribute](#EditorAttribute)&gt; | 返回编辑框属性值。 |
- 示例 - 示例
``` ```js
var EditorAttribute = TextInputClient.getEditorAttribute(); var EditorAttribute = TextInputClient.getEditorAttribute();
``` ```
......
...@@ -46,7 +46,7 @@ createPlainTextData(text:string): PasteData ...@@ -46,7 +46,7 @@ createPlainTextData(text:string): PasteData
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("content"); var pasteData = pasteboard.createPlainTextData("content");
``` ```
...@@ -71,7 +71,7 @@ createHtmlData(htmlText:string): PasteData ...@@ -71,7 +71,7 @@ createHtmlData(htmlText:string): PasteData
**示例** **示例**
``` ```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var pasteData = pasteboard.createHtmlData(html); var pasteData = pasteboard.createHtmlData(html);
``` ```
...@@ -97,7 +97,7 @@ createWantData(want:Want): PasteData ...@@ -97,7 +97,7 @@ createWantData(want:Want): PasteData
**示例** **示例**
``` ```js
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
...@@ -126,7 +126,7 @@ createUriData(uri:string): PasteData ...@@ -126,7 +126,7 @@ createUriData(uri:string): PasteData
**示例** **示例**
``` ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
``` ```
...@@ -151,7 +151,7 @@ createPlainTextRecord(text:string): PasteDataRecord ...@@ -151,7 +151,7 @@ createPlainTextRecord(text:string): PasteDataRecord
**示例** **示例**
``` ```js
var record = pasteboard.createPlainTextRecord("hello"); var record = pasteboard.createPlainTextRecord("hello");
``` ```
...@@ -176,7 +176,7 @@ createHtmlTextRecord(htmlText:string): PasteDataRecord ...@@ -176,7 +176,7 @@ createHtmlTextRecord(htmlText:string): PasteDataRecord
**示例** **示例**
``` ```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var record = pasteboard.createHtmlTextRecord(html); var record = pasteboard.createHtmlTextRecord(html);
``` ```
...@@ -202,7 +202,7 @@ createWantRecord(want:Want): PasteDataRecord ...@@ -202,7 +202,7 @@ createWantRecord(want:Want): PasteDataRecord
**示例** **示例**
``` ```js
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
...@@ -231,7 +231,7 @@ createUriRecord(uri:string): PasteDataRecord ...@@ -231,7 +231,7 @@ createUriRecord(uri:string): PasteDataRecord
**示例** **示例**
``` ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
``` ```
...@@ -284,7 +284,7 @@ convertToText(): Promise&lt;string&gt; ...@@ -284,7 +284,7 @@ convertToText(): Promise&lt;string&gt;
**示例** **示例**
``` ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
record.convertToText().then((data) => { record.convertToText().then((data) => {
console.info('convertToText success data : ' + JSON.stringify(data)); console.info('convertToText success data : ' + JSON.stringify(data));
...@@ -309,7 +309,7 @@ convertToText(callback: AsyncCallback&lt;string&gt;): void ...@@ -309,7 +309,7 @@ convertToText(callback: AsyncCallback&lt;string&gt;): void
**示例** **示例**
``` ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
record.convertToText((err, data) => { record.convertToText((err, data) => {
if (err) { if (err) {
...@@ -346,7 +346,7 @@ getPrimaryText(): string ...@@ -346,7 +346,7 @@ getPrimaryText(): string
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var plainText = pasteData.getPrimaryText(); var plainText = pasteData.getPrimaryText();
``` ```
...@@ -367,7 +367,7 @@ getPrimaryHtml(): string ...@@ -367,7 +367,7 @@ getPrimaryHtml(): string
**示例** **示例**
``` ```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var pasteData = pasteboard.createHtmlData(html); var pasteData = pasteboard.createHtmlData(html);
var htmlText = pasteData.getPrimaryHtml(); var htmlText = pasteData.getPrimaryHtml();
...@@ -389,7 +389,7 @@ getPrimaryWant(): Want ...@@ -389,7 +389,7 @@ getPrimaryWant(): Want
**示例** **示例**
``` ```js
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
...@@ -414,7 +414,7 @@ getPrimaryUri(): string ...@@ -414,7 +414,7 @@ getPrimaryUri(): string
**示例** **示例**
``` ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
var uri = pasteData.getPrimaryUri(); var uri = pasteData.getPrimaryUri();
``` ```
...@@ -437,7 +437,7 @@ addTextRecord(text: string): void ...@@ -437,7 +437,7 @@ addTextRecord(text: string): void
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
pasteData.addTextRecord("good"); pasteData.addTextRecord("good");
``` ```
...@@ -460,7 +460,7 @@ addHtmlRecord(htmlText: string): void ...@@ -460,7 +460,7 @@ addHtmlRecord(htmlText: string): void
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
pasteData.addHtmlRecord(html); pasteData.addHtmlRecord(html);
...@@ -484,7 +484,7 @@ addWantRecord(want: Want): void ...@@ -484,7 +484,7 @@ addWantRecord(want: Want): void
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
...@@ -511,7 +511,7 @@ addUriRecord(uri: string): void ...@@ -511,7 +511,7 @@ addUriRecord(uri: string): void
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt");
``` ```
...@@ -534,7 +534,7 @@ addRecord(record: PasteDataRecord): void ...@@ -534,7 +534,7 @@ addRecord(record: PasteDataRecord): void
**示例** **示例**
``` ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
var textRecord = pasteboard.createPlainTextRecord("hello"); var textRecord = pasteboard.createPlainTextRecord("hello");
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
...@@ -559,7 +559,7 @@ getMimeTypes(): Array&lt;string&gt; ...@@ -559,7 +559,7 @@ getMimeTypes(): Array&lt;string&gt;
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var types = pasteData.getMimeTypes(); var types = pasteData.getMimeTypes();
``` ```
...@@ -580,7 +580,7 @@ getPrimaryMimeType(): string ...@@ -580,7 +580,7 @@ getPrimaryMimeType(): string
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var type = pasteData.getPrimaryMimeType(); var type = pasteData.getPrimaryMimeType();
``` ```
...@@ -601,7 +601,7 @@ getProperty(): PasteDataProperty ...@@ -601,7 +601,7 @@ getProperty(): PasteDataProperty
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var property = pasteData.getProperty(); var property = pasteData.getProperty();
``` ```
...@@ -627,7 +627,7 @@ getRecordAt(index: number): PasteDataRecord ...@@ -627,7 +627,7 @@ getRecordAt(index: number): PasteDataRecord
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var record = pasteData.getRecordAt(0); var record = pasteData.getRecordAt(0);
``` ```
...@@ -648,7 +648,7 @@ getRecordCount(): number ...@@ -648,7 +648,7 @@ getRecordCount(): number
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var count = pasteData.getRecordCount(); var count = pasteData.getRecordCount();
``` ```
...@@ -669,7 +669,7 @@ getTag(): string ...@@ -669,7 +669,7 @@ getTag(): string
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var tag = pasteData.getTag(); var tag = pasteData.getTag();
``` ```
...@@ -695,7 +695,7 @@ hasMimeType(mimeType: string): boolean ...@@ -695,7 +695,7 @@ hasMimeType(mimeType: string): boolean
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN);
``` ```
...@@ -721,7 +721,7 @@ removeRecordAt(index: number): boolean ...@@ -721,7 +721,7 @@ removeRecordAt(index: number): boolean
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var isRemove = pasteData.removeRecordAt(0); var isRemove = pasteData.removeRecordAt(0);
``` ```
...@@ -748,7 +748,7 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean ...@@ -748,7 +748,7 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
var isReplace = pasteData.replaceRecordAt(0, record); var isReplace = pasteData.replaceRecordAt(0, record);
...@@ -770,7 +770,7 @@ getSystemPasteboard(): SystemPasteboard ...@@ -770,7 +770,7 @@ getSystemPasteboard(): SystemPasteboard
**示例** **示例**
``` ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
``` ```
...@@ -800,7 +800,7 @@ setPasteData(data:PasteData, callback:AsyncCallback&lt;void&gt;): void ...@@ -800,7 +800,7 @@ setPasteData(data:PasteData, callback:AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("content"); var pasteData = pasteboard.createPlainTextData("content");
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setPasteData(pasteData, (error, data) => { systemPasteboard.setPasteData(pasteData, (error, data) => {
...@@ -833,7 +833,7 @@ setPasteData(data:PasteData): Promise&lt;void&gt; ...@@ -833,7 +833,7 @@ setPasteData(data:PasteData): Promise&lt;void&gt;
**示例** **示例**
``` ```js
var pasteData = pasteboard.createPlainTextData("content"); var pasteData = pasteboard.createPlainTextData("content");
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setPasteData(pasteData).then((data) => { systemPasteboard.setPasteData(pasteData).then((data) => {
...@@ -859,7 +859,7 @@ getPasteData( callback:AsyncCallback&lt;PasteData&gt;): void ...@@ -859,7 +859,7 @@ getPasteData( callback:AsyncCallback&lt;PasteData&gt;): void
**示例** **示例**
``` ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getPasteData((error, pasteData) => { systemPasteboard.getPasteData((error, pasteData) => {
if (error) { if (error) {
...@@ -886,7 +886,7 @@ getPasteData(): Promise&lt;PasteData&gt; ...@@ -886,7 +886,7 @@ getPasteData(): Promise&lt;PasteData&gt;
**示例** **示例**
``` ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getPasteData().then((pasteData) => { systemPasteboard.getPasteData().then((pasteData) => {
var text = pasteData.getPrimaryText(); var text = pasteData.getPrimaryText();
...@@ -912,7 +912,7 @@ on(type: 'update', callback: () =&gt;void ): void ...@@ -912,7 +912,7 @@ on(type: 'update', callback: () =&gt;void ): void
**示例** **示例**
``` ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
var listener = ()=>{ var listener = ()=>{
console.info('The system pasteboard has changed'); console.info('The system pasteboard has changed');
...@@ -937,7 +937,7 @@ off(type: 'update', callback?: () =&gt;void ): void ...@@ -937,7 +937,7 @@ off(type: 'update', callback?: () =&gt;void ): void
**示例** **示例**
``` ```js
systemPasteboard.off('update', listener); systemPasteboard.off('update', listener);
``` ```
...@@ -957,7 +957,7 @@ hasPasteData(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -957,7 +957,7 @@ hasPasteData(callback: AsyncCallback&lt;boolean&gt;): void
**示例** **示例**
``` ```js
systemPasteboard.hasPasteData((err, data) => { systemPasteboard.hasPasteData((err, data) => {
if (err) { if (err) {
console.error('failed to hasPasteData because ' + JSON.stringify(err)); console.error('failed to hasPasteData because ' + JSON.stringify(err));
...@@ -983,7 +983,7 @@ hasPasteData(): Promise&lt;boolean&gt; ...@@ -983,7 +983,7 @@ hasPasteData(): Promise&lt;boolean&gt;
**示例** **示例**
``` ```js
systemPasteboard.hasPasteData().then((data) => { systemPasteboard.hasPasteData().then((data) => {
console.info('success hasPasteData : ' + JSON.stringify(data)); console.info('success hasPasteData : ' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -1007,7 +1007,7 @@ clear(callback: AsyncCallback&lt;void&gt;): void ...@@ -1007,7 +1007,7 @@ clear(callback: AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```js
systemPasteboard.clear((err, data) => { systemPasteboard.clear((err, data) => {
if (err) { if (err) {
console.error('failed to clear because ' + JSON.stringify(err)); console.error('failed to clear because ' + JSON.stringify(err));
...@@ -1034,7 +1034,7 @@ clear(): Promise&lt;void&gt; ...@@ -1034,7 +1034,7 @@ clear(): Promise&lt;void&gt;
**示例** **示例**
``` ```js
systemPasteboard.clear().then((data) => { systemPasteboard.clear().then((data) => {
console.info('success clear'); console.info('success clear');
}).catch((error) => { }).catch((error) => {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## 导入模块 ## 导入模块
``` ```
import systemTime from '@ohos.systemTime'; import systemTime from '@ohos.systemTime';
``` ```
...@@ -23,14 +23,14 @@ setTime(time : number, callback : AsyncCallback&lt;void&gt;) : void ...@@ -23,14 +23,14 @@ setTime(time : number, callback : AsyncCallback&lt;void&gt;) : void
**系统能力:** SystemCapability.Miscservices.Time **系统能力:** SystemCapability.Miscservices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| time | number | 是 | 目标时间戳(毫秒)。 | | time | number | 是 | 目标时间戳(毫秒)。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 |
- 示例: - 示例:
``` ```js
// time对应的时间为2021-01-20 02:36:25 // time对应的时间为2021-01-20 02:36:25
var time = 1611081385000; var time = 1611081385000;
systemTime.setTime(time, (error, data) => { systemTime.setTime(time, (error, data) => {
...@@ -54,18 +54,18 @@ setTime(time : number) : Promise&lt;void&gt; ...@@ -54,18 +54,18 @@ setTime(time : number) : Promise&lt;void&gt;
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| time | number | 是 | 目标时间戳(毫秒)。 | | time | number | 是 | 目标时间戳(毫秒)。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | 返回的异步回调函数。 | | Promise&lt;void&gt; | 返回的异步回调函数。 |
- 示例: - 示例:
``` ```js
// time对应的时间为2021-01-20 02:36:25 // time对应的时间为2021-01-20 02:36:25
var time = 1611081385000; var time = 1611081385000;
systemTime.setTime(time).then((data) => { systemTime.setTime(time).then((data) => {
...@@ -85,14 +85,14 @@ getCurrentTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void ...@@ -85,14 +85,14 @@ getCurrentTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 | | callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 |
- 示例: - 示例:
``` ```js
systemTime.getCurrentTime(true, (error, data) => { systemTime.getCurrentTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
...@@ -112,18 +112,18 @@ getCurrentTime(isNano?: boolean): Promise&lt;number&gt; ...@@ -112,18 +112,18 @@ getCurrentTime(isNano?: boolean): Promise&lt;number&gt;
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | 以Promise形式返回结果,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 | | Promise&lt;number&gt; | 以Promise形式返回结果,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 |
- 示例: - 示例:
``` ```js
systemTime.getCurrentTime().then((data) => { systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -141,14 +141,14 @@ getRealActiveTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void ...@@ -141,14 +141,14 @@ getRealActiveTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。 | | callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。 |
- 示例: - 示例:
``` ```js
systemTime.getRealActiveTime(true, (error, data) => { systemTime.getRealActiveTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error)); console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error));
...@@ -168,18 +168,18 @@ getRealActiveTime(isNano?: boolean): Promise&lt;number&gt; ...@@ -168,18 +168,18 @@ getRealActiveTime(isNano?: boolean): Promise&lt;number&gt;
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | 以Promise形式返回结果,返回自系统启动以来但不包括度睡眠时间经过的时间。 | | Promise&lt;number&gt; | 以Promise形式返回结果,返回自系统启动以来但不包括度睡眠时间经过的时间。 |
- 示例: - 示例:
``` ```js
systemTime.getCurrentTime().then((data) => { systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -197,14 +197,14 @@ getRealTime(callback: AsyncCallback&lt;number&gt;): void ...@@ -197,14 +197,14 @@ getRealTime(callback: AsyncCallback&lt;number&gt;): void
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来包括深度睡眠时间经过的毫秒数。 | | callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来包括深度睡眠时间经过的毫秒数。 |
- 示例: - 示例:
``` ```js
systemTime.getRealTime(true, (error, data) => { systemTime.getRealTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error));
...@@ -224,18 +224,18 @@ getRealTime(): Promise&lt;number&gt; ...@@ -224,18 +224,18 @@ getRealTime(): Promise&lt;number&gt;
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | 以Promise形式返回结果,返回自系统启动以来包括深度睡眠时间经过的时间。 | | Promise&lt;number&gt; | 以Promise形式返回结果,返回自系统启动以来包括深度睡眠时间经过的时间。 |
- 示例: - 示例:
``` ```js
systemTime.getRealTime().then((data) => { systemTime.getRealTime().then((data) => {
console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -255,14 +255,14 @@ setDate(date: Date, callback: AsyncCallback&lt;void&gt;): void ...@@ -255,14 +255,14 @@ setDate(date: Date, callback: AsyncCallback&lt;void&gt;): void
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| date | Date | 是 | 目标日期。 | | date | Date | 是 | 目标日期。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 |
- 示例: - 示例:
``` ```js
var data = new Date("October 13, 2020 11:13:00"); var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data,(error, data) => { systemTime.setDate(data,(error, data) => {
if (error) { if (error) {
...@@ -285,18 +285,18 @@ setDate(date: Date): Promise&lt;void&gt; ...@@ -285,18 +285,18 @@ setDate(date: Date): Promise&lt;void&gt;
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| date | Date | 是 | 目标日期。 | | date | Date | 是 | 目标日期。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | 返回的异步回调函数。 | | Promise&lt;void&gt; | 返回的异步回调函数。 |
- 示例: - 示例:
``` ```js
var data = new Date("October 13, 2020 11:13:00"); var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data).then((value) => { systemTime.setDate(data).then((value) => {
console.log(`systemTime.setDate success data : ` + JSON.stringify(value)); console.log(`systemTime.setDate success data : ` + JSON.stringify(value));
...@@ -315,13 +315,13 @@ getDate(callback: AsyncCallback&lt;Date&gt;): void ...@@ -315,13 +315,13 @@ getDate(callback: AsyncCallback&lt;Date&gt;): void
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Date&gt; | 是 | 回调函数,返回当前系统日期。 | | callback | AsyncCallback&lt;Date&gt; | 是 | 回调函数,返回当前系统日期。 |
- 示例: - 示例:
``` ```js
systemTime.getDate((error, data) => { systemTime.getDate((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getDate because ` + JSON.stringify(error)); console.error(`failed to systemTime.getDate because ` + JSON.stringify(error));
...@@ -341,13 +341,13 @@ getDate(): Promise&lt;Date&gt; ...@@ -341,13 +341,13 @@ getDate(): Promise&lt;Date&gt;
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;Date&gt; | 以Promise形式返回结果,返回当前系统日期。 | | Promise&lt;Date&gt; | 以Promise形式返回结果,返回当前系统日期。 |
- 示例: - 示例:
``` ```js
systemTime.getDate().then((data) => { systemTime.getDate().then((data) => {
console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); console.log(`systemTime.getDate success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -367,14 +367,14 @@ setTimezone(timezone: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -367,14 +367,14 @@ setTimezone(timezone: string, callback: AsyncCallback&lt;void&gt;): void
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| timezone | string | 是 | 系统时区。 | | timezone | string | 是 | 系统时区。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 |
- 示例: - 示例:
``` ```js
systemTime.setTimezone('Asia/Shanghai', (error, data) => { systemTime.setTimezone('Asia/Shanghai', (error, data) => {
if (error) { if (error) {
console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error)); console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error));
...@@ -396,18 +396,18 @@ setTimezone(timezone: string): Promise&lt;void&gt; ...@@ -396,18 +396,18 @@ setTimezone(timezone: string): Promise&lt;void&gt;
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| timezone | string | 是 | 系统时区。 | | timezone | string | 是 | 系统时区。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | 返回的异步回调函数。 | | Promise&lt;void&gt; | 返回的异步回调函数。 |
- 示例: - 示例:
``` ```js
systemTime.setTimezone('Asia/Shanghai').then((data) => { systemTime.setTimezone('Asia/Shanghai').then((data) => {
console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data)); console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -425,13 +425,13 @@ getTimezone(callback: AsyncCallback&lt;string&gt;): void ...@@ -425,13 +425,13 @@ getTimezone(callback: AsyncCallback&lt;string&gt;): void
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调函数,返回系统时区。 | | callback | AsyncCallback&lt;string&gt; | 是 | 回调函数,返回系统时区。 |
- 示例: - 示例:
``` ```js
systemTime.getTimezone((error, data) => { systemTime.getTimezone((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error)); console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error));
...@@ -451,13 +451,13 @@ getTimezone(): Promise&lt;string&gt; ...@@ -451,13 +451,13 @@ getTimezone(): Promise&lt;string&gt;
**系统能力:** SystemCapability.MiscServices.Time **系统能力:** SystemCapability.MiscServices.Time
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;string&gt; | 以Promise形式返回结果,返回系统时区。 | | Promise&lt;string&gt; | 以Promise形式返回结果,返回系统时区。 |
- 示例: - 示例:
``` ```js
systemTime.getTimezone().then((data) => { systemTime.getTimezone().then((data) => {
console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data)); console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
......
...@@ -18,10 +18,10 @@ import wallpaper from '@ohos.wallpaper'; ...@@ -18,10 +18,10 @@ import wallpaper from '@ohos.wallpaper';
**系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。 **系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。
| 名称 | 说明 | | 名称 | 说明 |
| -------- | -------- | | -------- | -------- |
| WALLPAPER_LOCKSCREEN | 锁屏壁纸标识。 | | WALLPAPER_LOCKSCREEN | 锁屏壁纸标识。 |
| WALLPAPER_SYSTEM | 主屏幕壁纸标识。 | | WALLPAPER_SYSTEM | 主屏幕壁纸标识。 |
## wallpaper.getColors ## wallpaper.getColors
...@@ -33,14 +33,14 @@ getColors(wallpaperType: WallpaperType, callback: AsyncCallback&lt;Array&lt;Rgba ...@@ -33,14 +33,14 @@ getColors(wallpaperType: WallpaperType, callback: AsyncCallback&lt;Array&lt;Rgba
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| callback | AsyncCallback&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | 是 | 回调函数,返回壁纸的主要颜色信息。 | | callback | AsyncCallback&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | 是 | 回调函数,返回壁纸的主要颜色信息。 |
- 示例: - 示例:
``` ```js
wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to getColors because: ` + JSON.stringify(error)); console.error(`failed to getColors because: ` + JSON.stringify(error));
...@@ -60,18 +60,18 @@ getColors(wallpaperType: WallpaperType): Promise&lt;Array&lt;RgbaColor&gt;&gt; ...@@ -60,18 +60,18 @@ getColors(wallpaperType: WallpaperType): Promise&lt;Array&lt;RgbaColor&gt;&gt;
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | 返回壁纸的主要颜色信息。 | | Promise&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | 返回壁纸的主要颜色信息。 |
- 示例: - 示例:
``` ```js
wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getColors.`); console.log(`success to getColors.`);
}).catch((error) => { }).catch((error) => {
...@@ -89,14 +89,14 @@ getId(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): void ...@@ -89,14 +89,14 @@ getId(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): void
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数 - 参数
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回壁纸的ID。如果配置了指定类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | | callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回壁纸的ID。如果配置了指定类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 |
- 示例: - 示例:
``` ```js
wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to getId because: ` + JSON.stringify(error)); console.error(`failed to getId because: ` + JSON.stringify(error));
...@@ -117,18 +117,18 @@ getId(wallpaperType: WallpaperType): Promise&lt;number&gt; ...@@ -117,18 +117,18 @@ getId(wallpaperType: WallpaperType): Promise&lt;number&gt;
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | 壁纸的ID。如果配置了这种壁纸类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | | Promise&lt;number&gt; | 壁纸的ID。如果配置了这种壁纸类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 |
- 示例: - 示例:
``` ```js
wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getId: ` + JSON.stringify(data)); console.log(`success to getId: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -146,13 +146,13 @@ getMinHeight(callback: AsyncCallback&lt;number&gt;): void ...@@ -146,13 +146,13 @@ getMinHeight(callback: AsyncCallback&lt;number&gt;): void
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | | callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 |
- 示例: - 示例:
``` ```js
wallpaper.getMinHeight((error, data) => { wallpaper.getMinHeight((error, data) => {
if (error) { if (error) {
console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
...@@ -173,13 +173,13 @@ getMinHeight(): Promise&lt;number&gt; ...@@ -173,13 +173,13 @@ getMinHeight(): Promise&lt;number&gt;
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | 返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | | Promise&lt;number&gt; | 返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 |
- 示例: - 示例:
``` ```js
wallpaper.getMinHeight().then((data) => { wallpaper.getMinHeight().then((data) => {
console.log(`success to getMinHeight: ` + JSON.stringify(data)); console.log(`success to getMinHeight: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -198,13 +198,13 @@ getMinWidth(callback: AsyncCallback&lt;number&gt;): void ...@@ -198,13 +198,13 @@ getMinWidth(callback: AsyncCallback&lt;number&gt;): void
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | | callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 |
- 示例: - 示例:
``` ```js
wallpaper.getMinWidth((error, data) => { wallpaper.getMinWidth((error, data) => {
if (error) { if (error) {
console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
...@@ -224,13 +224,13 @@ getMinWidth(): Promise&lt;number&gt; ...@@ -224,13 +224,13 @@ getMinWidth(): Promise&lt;number&gt;
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | 壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | | Promise&lt;number&gt; | 壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 |
- 示例: - 示例:
``` ```js
wallpaper.getMinWidth().then((data) => { wallpaper.getMinWidth().then((data) => {
console.log(`success to getMinWidth: ` + JSON.stringify(data)); console.log(`success to getMinWidth: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -248,13 +248,13 @@ isChangePermitted(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -248,13 +248,13 @@ isChangePermitted(callback: AsyncCallback&lt;boolean&gt;): void
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 |
- 示例: - 示例:
``` ```js
wallpaper.isChangePermitted((error, data) => { wallpaper.isChangePermitted((error, data) => {
if (error) { if (error) {
console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
...@@ -274,13 +274,13 @@ isChangePermitted(): Promise&lt;boolean&gt; ...@@ -274,13 +274,13 @@ isChangePermitted(): Promise&lt;boolean&gt;
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | 返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | | Promise&lt;boolean&gt; | 返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 |
- 示例: - 示例:
``` ```js
wallpaper.isChangePermitted().then((data) => { wallpaper.isChangePermitted().then((data) => {
console.log(`success to isChangePermitted: ` + JSON.stringify(data)); console.log(`success to isChangePermitted: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -298,13 +298,13 @@ isOperationAllowed(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -298,13 +298,13 @@ isOperationAllowed(callback: AsyncCallback&lt;boolean&gt;): void
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 |
- 示例: - 示例:
``` ```js
wallpaper.isOperationAllowed((error, data) => { wallpaper.isOperationAllowed((error, data) => {
if (error) { if (error) {
console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
...@@ -324,13 +324,13 @@ isOperationAllowed(): Promise&lt;boolean&gt; ...@@ -324,13 +324,13 @@ isOperationAllowed(): Promise&lt;boolean&gt;
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | 异步回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | | Promise&lt;boolean&gt; | 异步回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 |
- 示例: - 示例:
``` ```js
wallpaper.isOperationAllowed().then((data) => { wallpaper.isOperationAllowed().then((data) => {
console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -350,14 +350,14 @@ reset(wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void ...@@ -350,14 +350,14 @@ reset(wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,调用成功则返回是否移除成功的结果,调用失败则返回error信息。 |
- 示例: - 示例:
``` ```js
wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to reset because: ` + JSON.stringify(error)); console.error(`failed to reset because: ` + JSON.stringify(error));
...@@ -379,18 +379,18 @@ reset(wallpaperType: WallpaperType): Promise&lt;void&gt; ...@@ -379,18 +379,18 @@ reset(wallpaperType: WallpaperType): Promise&lt;void&gt;
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | 调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | | Promise&lt;void&gt; | 调用成功则返回是否移除成功的结果,调用失败则返回error信息。 |
- 示例: - 示例:
``` ```js
wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to reset.`); console.log(`success to reset.`);
}).catch((error) => { }).catch((error) => {
...@@ -418,7 +418,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, call ...@@ -418,7 +418,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, call
- 示例: - 示例:
``` ```js
// source类型为string // source类型为string
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
...@@ -469,13 +469,13 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Pro ...@@ -469,13 +469,13 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Pro
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | 调用成功则返回是返回设置的结果,调用失败则返回error信息。 | | Promise&lt;void&gt; | 调用成功则返回是返回设置的结果,调用失败则返回error信息。 |
- 示例: - 示例:
``` ```js
// source类型为string // source类型为string
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
...@@ -515,14 +515,14 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): vo ...@@ -515,14 +515,14 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): vo
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | | callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 |
- 示例: - 示例:
``` ```js
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to getFile because: ` + JSON.stringify(error)); console.error(`failed to getFile because: ` + JSON.stringify(error));
...@@ -543,18 +543,18 @@ getFile(wallpaperType: WallpaperType): Promise&lt;number&gt; ...@@ -543,18 +543,18 @@ getFile(wallpaperType: WallpaperType): Promise&lt;number&gt;
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | 调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | | Promise&lt;number&gt; | 调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 |
- 示例: - 示例:
``` ```js
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getFile: ` + JSON.stringify(data)); console.log(`success to getFile: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -579,7 +579,7 @@ on(type: 'colorChange', callback: (colors: Array&lt;RgbaColor&gt;, wallpaperType ...@@ -579,7 +579,7 @@ on(type: 'colorChange', callback: (colors: Array&lt;RgbaColor&gt;, wallpaperType
- 示例: - 示例:
``` ```js
let listener = (colors, wallpaperType) => { let listener = (colors, wallpaperType) => {
console.log(`wallpaper color changed.`); console.log(`wallpaper color changed.`);
}; };
...@@ -596,14 +596,14 @@ off(type: 'colorChange', callback?: (colors: Array&lt;RgbaColor&gt;, wallpaperTy ...@@ -596,14 +596,14 @@ off(type: 'colorChange', callback?: (colors: Array&lt;RgbaColor&gt;, wallpaperTy
**系统能力**: SystemCapability.MiscServices.Wallpaper **系统能力**: SystemCapability.MiscServices.Wallpaper
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | 是 | 取值为'colorChange',表示取消订阅壁纸颜色变化结果上报事件。 | | type | string | 是 | 取值为'colorChange',表示取消订阅壁纸颜色变化结果上报事件。 |
| callback | function | 否 | &nbsp;&nbsp;表示取消壁纸颜色变化结果上报,不填写该参数则取消订阅该type对应的所有回调。<br/>-&nbsp;colors<br/>&nbsp;&nbsp;壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。<br/>-&nbsp;wallpaperType<br/>&nbsp;&nbsp;壁纸类型。 | | callback | function | 否 | &nbsp;&nbsp;表示取消壁纸颜色变化结果上报,不填写该参数则取消订阅该type对应的所有回调。<br/>-&nbsp;colors<br/>&nbsp;&nbsp;壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。<br/>-&nbsp;wallpaperType<br/>&nbsp;&nbsp;壁纸类型。 |
- 示例: - 示例:
``` ```js
let listener = (colors, wallpaperType) => { let listener = (colors, wallpaperType) => {
console.log(`wallpaper color changed.`); console.log(`wallpaper color changed.`);
}; };
...@@ -619,9 +619,9 @@ off(type: 'colorChange', callback?: (colors: Array&lt;RgbaColor&gt;, wallpaperTy ...@@ -619,9 +619,9 @@ off(type: 'colorChange', callback?: (colors: Array&lt;RgbaColor&gt;, wallpaperTy
**系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。 **系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| red | number | 是 | 是 | 表示红色值,范围为&nbsp;0&nbsp;&nbsp;255。 | | red | number | 是 | 是 | 表示红色值,范围为&nbsp;0&nbsp;&nbsp;255。 |
| green | number | 是 | 是 | 表示绿色值,范围为&nbsp;0&nbsp;&nbsp;255。 | | green | number | 是 | 是 | 表示绿色值,范围为&nbsp;0&nbsp;&nbsp;255。 |
| blue | number | 是 | 是 | 表示蓝色值,范围为&nbsp;0&nbsp;&nbsp;255。 | | blue | number | 是 | 是 | 表示蓝色值,范围为&nbsp;0&nbsp;&nbsp;255。 |
| alpha | number | 是 | 是 | 表示&nbsp;alpha&nbsp;值,范围为&nbsp;0&nbsp;&nbsp;255。 | | alpha | number | 是 | 是 | 表示&nbsp;alpha&nbsp;值,范围为&nbsp;0&nbsp;&nbsp;255。 |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册