All Products
Search
Document Center

SuperApp:Screen

Last Updated:Oct 25, 2024

This topic describes the JavaScript APIs of WVScreen. You can refer to this topic when you create HTML5 apps or Miniapps. The JavaScript APIs of WVScreen provide the capabilities to set and obtain the display orientation (landscape or portrait) of the current activity or view controller, and set and obtain the screen brightness.

WVScreen.getOrientation

Obtains the display orientation (landscape or portrait) of the current activity or view controller.

Input parameters

No input parameters exist.

Callback parameters

Callback parameters are passed into the callback method. If the display orientation is obtained, the success callback is invoked. Otherwise, the failure callback is invoked.

  • [string]orientation: the display orientation of the current activity or view controller. Valid values:

    • 'landscape'

    • 'portrait'

    • 'unknown'

window.WindVane.call('WVScreen', 'getOrientation', {}, function(e) {
        alert('success: ' + JSON.stringify(e));
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVScreen.setOrientation

Sets the display orientation (landscape or portrait) of the current activity or view controller. Note that WVScreen also affects the display orientation of the pages to which WebView redirects. Therefore, the display orientation must be restored each time WebView redirects to a page.

Input parameters

  • [string]orientation: the display orientation of the activity. Valid values:

    • 'default': the default display orientation of the client.

    • 'landscape': the landscape display orientation. The display orientation is automatically switched to the left landscape or right landscape mode based on how the device is held. This automatic switching may not be supported on some clients.

    • 'portrait': the portrait display orientation.

    • 'landscapeRight': the landscape right orientation, where the display is rotated 90 degrees counterclockwise.

    • 'landscapeLeft': the landscape left orientation, where the display is rotated 90 degrees clockwise.

    • 'portraitUpsideDown': the reversed portrait orientation.

    • 'auto': specifies to automatically switch the display orientation.

Callback parameters

No callback parameters exist. If the display orientation is set, the success callback is invoked. Otherwise, the failure callback is invoked.

var params = {
        orientation: 'landscape'
};
window.WindVane.call('WVScreen', 'setOrientation', params, function(e) {
        alert('success: ' + JSON.stringify(e));
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVScreen.setScreenBrightness

Note

This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.

Sets the screen brightness.

Input parameters

  • [number]brightness: the screen brightness. Valid values: 0 to 255.

Callback parameters

Parameters for the success callback:

  • No callback parameters exist.

Parameters for the failure callback:

  • [string]msg: the error message.

var params = {
       brightness: '100'
};
window.WindVane.call('WVScreen', 'setScreenBrightness', params, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVScreen.getScreenBrightness

Note

This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.

Obtains the screen brightness.

Input parameters

  • No input parameters exist.

Callback parameters

  • [string]brightness: the screen brightness.

window.WindVane.call('WVScreen', 'getScreenBrightness', {}, function(e) {
        alert('success: ' + JSON.stringify(e));
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});