Hardware
API Reference: Device.Hardware
Hardware is used to retrieve certain device hardware information.
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 Hardware from '@smartface/native/device/hardware';
5
6
//You should create new Page from UI-Editor and extend with it.
7
export default class Sample extends PageSampleDesign {
8
9
constructor() {
10
super();
11
// Overrides super.onShow method
12
this.onShow = onShow.bind(this, this.onShow.bind(this));
13
// Overrides super.onLoad method
14
this.onLoad = onLoad.bind(this, this.onLoad.bind(this));
15
16
this.layout.flexDirection = FlexLayout.FlexDirection.COLUMN;
17
this.layout.justifyContent = FlexLayout.JustifyContent.CENTER;
18
this.layout.alignItems = FlexLayout.AlignItems.CENTER;
19
}
20
}
21
22
/**
23
* @event onShow
24
* This event is called when a page appears on the screen (everytime).
25
* @param {function} superOnShow super onShow function
26
* @param {Object} parameters passed from Router.go function
27
*/
28
function onShow(superOnShow: () => void) {
29
const { headerBar } = this;
30
superOnShow();
31
Application.statusBar.visible = false;
32
headerBar.visible = false;
33
}
34
35
/**
36
* @event onLoad
37
* This event is called once when page is created.
38
* @param {function} superOnLoad super onLoad function
39
*/
40
function onLoad(superOnLoad: () => void) {
41
superOnLoad();
42
43
console.log("Device.Hardware.IMEI: " + Hardware.android.IMEI);
44
console.log("Device.Hardware.UID: " + Hardware.UID);
45
console.log("Device.Hardware.brandName: " + Hardware.brandName);
46
console.log("Device.Hardware.brandModel: " + Hardware.brandModel);
47
console.log("Device.Hardware.vendorID: " + Hardware.android.vendorID);
48
}
49
Copied!
Last modified 2mo ago
Copy link