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

!20994 bindDialogTarget接口示例代码更新

Merge pull request !20994 from ZhengJiangliang/cherry-pick-1689652590
...@@ -3063,7 +3063,16 @@ class TestRemoteObject extends rpc.RemoteObject { ...@@ -3063,7 +3063,16 @@ class TestRemoteObject extends rpc.RemoteObject {
} }
let token = new TestRemoteObject('testObject'); let token = new TestRemoteObject('testObject');
let windowClass = null;
let config = {name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context};
try { try {
window.createWindow(config, (err, data) => {
if (err.code) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
});
windowClass.bindDialogTarget(token, () => { windowClass.bindDialogTarget(token, () => {
console.info('Dialog Window Need Destroy.'); console.info('Dialog Window Need Destroy.');
}, (err) => { }, (err) => {
...@@ -3136,7 +3145,16 @@ class TestRemoteObject extends rpc.RemoteObject { ...@@ -3136,7 +3145,16 @@ class TestRemoteObject extends rpc.RemoteObject {
} }
let token = new TestRemoteObject('testObject'); let token = new TestRemoteObject('testObject');
let windowClass = null;
let config = {name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context};
try { try {
window.createWindow(config, (err, data) => {
if (err.code) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
});
let promise = windowClass.bindDialogTarget(token, () => { let promise = windowClass.bindDialogTarget(token, () => {
console.info('Dialog Window Need Destroy.'); console.info('Dialog Window Need Destroy.');
}); });
...@@ -3192,7 +3210,16 @@ export default class ServiceExtAbility extends ServiceExtensionAbility { ...@@ -3192,7 +3210,16 @@ export default class ServiceExtAbility extends ServiceExtensionAbility {
onRequest(want, startId) { onRequest(want, startId) {
console.info('onRequest'); console.info('onRequest');
let windowClass = null;
let config = {name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context};
try { try {
window.createWindow(config, (err, data) => {
if (err.code) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
});
let requestInfo = dialogRequest.getRequestInfo(want) let requestInfo = dialogRequest.getRequestInfo(want)
windowClass.bindDialogTarget(requestInfo, () => { windowClass.bindDialogTarget(requestInfo, () => {
console.info('Dialog Window Need Destroy.'); console.info('Dialog Window Need Destroy.');
...@@ -3204,7 +3231,7 @@ export default class ServiceExtAbility extends ServiceExtensionAbility { ...@@ -3204,7 +3231,7 @@ export default class ServiceExtAbility extends ServiceExtensionAbility {
console.info('Succeeded in binding dialog target.'); console.info('Succeeded in binding dialog target.');
}); });
} catch(err) { } catch(err) {
console.error('getRequestInfo err = ' + JSON.stringify(err)) console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err))
} }
} }
...@@ -3269,7 +3296,16 @@ export default class ServiceExtAbility extends ServiceExtensionAbility { ...@@ -3269,7 +3296,16 @@ export default class ServiceExtAbility extends ServiceExtensionAbility {
onRequest(want, startId) { onRequest(want, startId) {
console.info('onRequest'); console.info('onRequest');
let windowClass = null;
let config = {name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context};
try { try {
window.createWindow(config, (err, data) => {
if (err.code) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
});
let requestInfo = dialogRequest.getRequestInfo(want) let requestInfo = dialogRequest.getRequestInfo(want)
let promise = windowClass.bindDialogTarget(requestInfo, () => { let promise = windowClass.bindDialogTarget(requestInfo, () => {
console.info('Dialog Window Need Destroy.'); console.info('Dialog Window Need Destroy.');
...@@ -3280,7 +3316,7 @@ export default class ServiceExtAbility extends ServiceExtensionAbility { ...@@ -3280,7 +3316,7 @@ export default class ServiceExtAbility extends ServiceExtensionAbility {
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
}); });
} catch(err) { } catch(err) {
console.error('getRequestInfo err = ' + JSON.stringify(err)) console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err))
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册