English
Get device settings
Platform Difference Description
| App | H5 | 微信小程序 | 支付宝小程序 | 百度小程序 | 抖音小程序、飞书小程序 | 钉钉小程序 | QQ小程序 | 快手小程序 | 京东小程序 | 元服务 |
|---|---|---|---|---|---|---|---|---|---|---|
| HBuilderX (3.5.2+) | x | 基础库 (2.20.1+) | x | x | x | x | x | x | x | x |
| HarmonyOS |
|---|
| HBuilderX 4.31 |
Return parameter description
| property | type | description |
|---|---|---|
| bluetoothEnabled | boolean | System switch for bluetooth. When the value is false, on the App side: it may be caused by incorrect configuration. In this case, the bluetoothError attribute description error will be returned. |
| bluetoothError | String | App: Returns a string when the Android platform does not have permission or the iOS platform module configuration is incorrect, otherwise this property is not returned. See below for details |
| locationEnabled | boolean | System switch for location. When the value is false, App side: Android platform is accurate; iOS platform may be caused by incorrect configuration, in this case, locationError property description error will be returned. |
| locationError | String | App: Android platform does not return this property; iOS platform module configuration error returns a string, otherwise this property is not returned. See below for details |
| wifiEnabled | boolean | Wi-Fi 的系统开关 |
| wifiError | String | App端:Android平台没有权限时返回此属性;iOS平台不返回此属性;。详情见下 |
| deviceOrientation | string | Device orientation. Portrait: portrait, Landscape: landscape |
| 类型 |
|---|
| GetSystemSettingResult |
|:-|:-|:-|:-|:-:|:-| |bluetoothEnabled|boolean|否|-| | |bluetoothError|string|否|-| | |locationEnabled|boolean|是|-| | |wifiEnabled|boolean|否|-| | |wifiError|string|否|-| | |deviceOrientation|string|是|-| | |
Tips
bluetoothError:
"Missing permissions required by BluetoothAdapter.isEnabled: android.permission.BLUETOOTH" means there is no android.permission.BLUETOOTH permission"Missing bluetooth module in manifest.json" , indicating that the BlueTooth (Bluetooth Low Energy) module is not configured in manifest.json -> App Module ConfigurationlocationError:
wifiError "Missing permissions required by WifiManager.isWifiEnabled: android.permission.ACCESS_WIFI_STATE" 表示没有 android.permission.ACCESS_WIFI_STATE 权限Example
const systemSetting = uni.getSystemSetting()
console.log(systemSetting.bluetoothEnabled)
console.log(systemSetting.deviceOrientation)
console.log(systemSetting.locationEnabled)
console.log(systemSetting.wifiEnabled)