How to code an app in Huawei GT 2 Pro wear to always keep on the screen active?

292 Views Asked by At

I investigated and Although I read documentations of Huawei Wear Engine, I couldn't find any things. I knows this I should change power or keep-on setting but I did not find anthing. Even I know implementing a service to will affect system configuration but there is no any document about it. Could you help me about implement always keep on screen huawei GT2 Pro.

2

There are 2 best solutions below

0
On

Keeping screen on could be achieved via brightness.setKeepScreenOn(OBJECT) https://developer.harmonyos.com/en/docs/documentation/doc-references/lite-wearable-system-screen-brightness-0000001122145264

Sample code is as follows:

brightness.setKeepScreenOn({ keepScreenOn: true, success: function () { console.log('handling set keep screen on success.') }, fail: function (data, code) { console.log('handling set keep screen on fail, code:' + code + ', data: ' + data); }, });

0
On

As@Zinna mentioned, You can call brightness.setKeepScreenOn(OBJECT) to always keep on the screen active.

Examples are as follows:

brightness.setKeepScreenOn({
  keepScreenOn: true,
  success: function () {
    console.log('handling set keep screen on success.')
  },
  fail: function (data, code) {
    console.log('handling set keep screen on fail, code:' + code + ', data: ' + data);
  },
});

You are advised to invoke it in the onShow() phase to always keep the screen on.

For details, kindly refer to this Docs.