System
API Reference: Device.System
System is used to retrieve operating system-specific information of the device.
TypeScript
1
import PageSampleDesign from 'generated/pages/pageSample';
2
import FlexLayout from '@smartface/native/ui/flexlayout';
3
import Application from '@smartface/native/application';
4
import Button from '@smartface/native/ui/button';
5
import Sound from '@smartface/native/device/sound';
6
import System from '@smartface/native/device/system';
7
8
//You should create new Page from UI-Editor and extend with it.
9
export default class Sample extends PageSampleDesign {
10
11
mySound: Sound;
12
myButton: Button;
13
14
constructor() {
15
super();
16
// Overrides super.onShow method
17
this.onShow = onShow.bind(this, this.onShow.bind(this));
18
// Overrides super.onLoad method
19
this.onLoad = onLoad.bind(this, this.onLoad.bind(this));
20
21
this.layout.flexDirection = FlexLayout.FlexDirection.COLUMN;
22
this.layout.justifyContent = FlexLayout.JustifyContent.CENTER;
23
this.layout.alignItems = FlexLayout.AlignItems.CENTER;
24
}
25
}
26
27
/**
28
* @event onShow
29
* This event is called when a page appears on the screen (everytime).
30
* @param {function} superOnShow super onShow function
31
* @param {Object} parameters passed from Router.go function
32
*/
33
function onShow(superOnShow: () => void) {
34
const { headerBar } = this;
35
superOnShow();
36
Application.statusBar.visible = false;
37
headerBar.visible = false;
38
}
39
40
/**
41
* @event onLoad
42
* This event is called once when page is created.
43
* @param {function} superOnLoad super onLoad function
44
*/
45
function onLoad(superOnLoad: () => void) {
46
superOnLoad();
47
console.log("Device.System.OS: " + System.OS);
48
console.log("Device.System.OSVersion: " + System.OSVersion);
49
console.log("Device.System.android.apiLevel: " + System.android.apiLevel);
50
console.log("Device.System.batteryLevel: " + System.batteryLevel);
51
console.log("Device.System.isBatteryCharged: " + System.isBatteryCharged);
52
console.log("Device.System.language: " + System.language);
53
//@ts-ignore
54
console.log("Device.System.android.isApplicationInstalled: " + System.android.isApplicationInstalled('io.smartface.SmartfaceApp'));
55
//@ts-ignore
56
console.log("Device.System.vibrate(): " + System.vibrate());
57
console.log("Device.System.android.menuKeyAvaliable: " + System.android.menuKeyAvaliable);
58
console.log("Device.System.fingerPrintAvailable: " + System.fingerPrintAvailable);
59
60
}
61
Copied!
Last modified 2mo ago
Copy link