Class

# System.DeviceData

<div class="rst-class">

forsearch

</div>

DeviceData

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Provides information about the mobile device such as battery level, orientation and more.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                                | Type                                                | Read-Only | Shared |
|---------------------------------------------------------------------|-----------------------------------------------------|-----------|--------|
| `BatteryLevel<devicedata.batterylevel>`                             | `Double</api/data_types/double>`                    | ✓         |        |
| `BatteryMonitoringEnabled<devicedata.batterymonitoringenabled>`     | `Boolean</api/data_types/boolean>`                  |           |        |
| `BatteryState<devicedata.batterystate>`                             | `BatteryStates<devicedata.batterystates>`           | ✓         |        |
| `Identifier<devicedata.identifier>`                                 | `String</api/data_types/string>`                    | ✓         |        |
| `IsProximityNear<devicedata.isproximitynear>`                       | `Boolean</api/data_types/boolean>`                  | ✓         |        |
| `IsRunningOnDevice<devicedata.isrunningondevice>`                   | `Boolean</api/data_types/boolean>`                  | ✓         |        |
| `LocalizedModel<devicedata.localizedmodel>`                         | `String</api/data_types/string>`                    | ✓         |        |
| `Model<devicedata.model>`                                           | `String</api/data_types/string>`                    | ✓         |        |
| `Name<devicedata.name>`                                             | `String</api/data_types/string>`                    | ✓         |        |
| `Orientation<devicedata.orientation>`                               | `Orientations<devicedata.orientations>`             | ✓         |        |
| `ProximityMonitoringEnabled<devicedata.proximitymonitoringenabled>` | `Boolean</api/data_types/boolean>`                  |           |        |
| `UserInterfaceType<devicedata.userinterfacetype>`                   | `UserInterfaceTypes<devicedata.userinterfacetypes>` | ✓         |        |

## Enumerations

<div id="devicedata.batterystates">

<div class="rst-class">

forsearch

</div>

</div>

DeviceData.BatteryStates

### BatteryStates

> The possible charging states of the battery.
>
> | Enum      | Description                                                                          |
> |-----------|--------------------------------------------------------------------------------------|
> | Unknown   | The current state of the battery cannot be determined.                               |
> | Unplugged | The device is not plugged into a power source and the battery level is discharging.  |
> | Charging  | The device is plugged into a power source but the battery is less than 100% charged. |
> | Full      | The device is plugged into a power source but the battery is 100% charged.           |

<div id="devicedata.orientations">

<div class="rst-class">

forsearch

</div>

</div>

DeviceData.Orientations

### Orientations

> The positions a device can be in.
>
> | Enum               | Description                                                                                |
> |--------------------|--------------------------------------------------------------------------------------------|
> | Unknown            | The orientation of the device cannot be determined.                                        |
> | Portrait           | The device is perpendicular to the ground with the top of the device pointed upward.       |
> | PortraitUpsideDown | The device is perpendicular to the ground with the bottom of the device pointed upward.    |
> | LandscapeLeft      | The device is perpendicular to the ground with the top of the device pointed to the left.  |
> | LandscapeRight     | The device is perpendicular to the ground with the top of the device pointed to the right. |
> | FaceUp             | The device is parallel to the ground with the screen facing upward.                        |
> | FaceDown           | The device is parallel to the ground with the screen facing downward.                      |

<div id="devicedata.userinterfacetypes">

<div class="rst-class">

forsearch

</div>

</div>

DeviceData.UserInterfaceTypes

### UserInterfaceTypes

> The various possible device types.
>
> | Enum        | Description                                 |
> |-------------|---------------------------------------------|
> | Unspecified | The user interface type was not specified.  |
> | Phone       | The user interface is that of a smartphone. |
> | Tablet      | The user interface is that of a tablet.     |

## Property descriptions

<div id="devicedata.batterylevel">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DeviceData.BatteryLevel

**BatteryLevel** As `Double</api/data_types/double>`

> The amount of battery remaining.
>
> This property is read-only.
>
> A value of 0.0 means the battery is full discharged. A value of 1.0 means the battery is fully charged.
>
> This example enables monitoring of the battery, gets the current battery level, disables battery monitoring and then displays the level in a message box:
>
> ``` xojo
> System.Device.BatteryMonitoringEnabled = True
>
> Var batteryPercentage As Integer = System.Device.BatteryLevel * 100
> System.Device.BatteryMonitoringEnabled = False
>
> MessageBox("Your battery is at " + batteryPercentage.ToString + "%")
> ```

<div id="devicedata.batterymonitoringenabled">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DeviceData.BatteryMonitoringEnabled

**BatteryMonitoringEnabled** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the `BatteryLevel<devicedata.batterylevel>` and `BatteryState<devicedata.batterystate>` will be updated.
>
> To preserve battery, set this property to `True</api/language/true>` only while you need to have up to date battery information then set it back to `False</api/language/false>`.
>
> This example enables monitoring of the battery, gets the current battery level, disables battery monitoring and then displays the level in a message box:
>
> ``` xojo
> System.Device.BatteryMonitoringEnabled = True
>
> Var batteryPercentage As Integer = System.Device.BatteryLevel * 100
> System.Device.BatteryMonitoringEnabled = False
>
> MessageBox("Your battery is at " + batteryPercentage.ToString + "%")
> ```

<div id="devicedata.batterystate">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DeviceData.BatteryState

**BatteryState** As `BatteryStates<devicedata.batterystates>`

> Indicates if the battery is charging, fully charged, etc.
>
> This property is read-only.
>
> To get the current state of the battery, `BatteryMonitoringEnabled<devicedata.batterymonitoringenabled>` must be `True</api/language/true>`. One you no longer need to know the current battery state, set `BatteryMonitoringEnabled<devicedata.batterymonitoringenabled>` to `False</api/language/false>`.
>
> To get the current state of the battery, add this to your MobileButton Pressed event
>
> ``` xojo
> Var data As System.DeviceData = System.Device
>
> Select Case data.BatteryState
> Case System.DeviceData.BatteryStates.Charging
>   MessageBox("Charging")
> Case System.DeviceData.BatteryStates.Full
>   MessageBox("Full")
> Case System.DeviceData.BatteryStates.Unknown
>   MessageBox("Unknown")
> Case System.DeviceData.BatteryStates.Unplugged
>   MessageBox("Unplugged")
> End Select
> ```

<div id="devicedata.identifier">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DeviceData.Identifier

**Identifier** As `String</api/data_types/string>`

> A string of characters that uniquely identifies the device.
>
> This property is read-only.

<div id="devicedata.isproximitynear">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DeviceData.IsProximityNear

**IsProximityNear** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the device is near the user.
>
> This property is read-only.
>
> The `ProximityMonitoringEnabled<devicedata.proximitymonitoringenabled>` property must be `True</api/language/true>` for this property to return accurate information. To preserver battery power, only set `ProximityMonitoringEnabled<devicedata.proximitymonitoringenabled>` to `True</api/language/true>` while calling IsProximityNear and then set it to `False</api/language/false>` as soon as you no longer need it.
>
> If the device is near the user, display a message:
>
> ``` xojo
> System.Device.ProximityMonitoringEnabled = True
>
> If System.Device.IsProximityNear Then
>   MessageBox("The device is close to you.")
> End If
>
> System.Device.ProximityMonitoringEnabled = False
> ```

<div id="devicedata.isrunningondevice">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DeviceData.IsRunningOnDevice

**IsRunningOnDevice** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the app is running on a physical device rather then in an emulator.
>
> This property is read-only.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This is supported for Android only.
>
> </div>

<div id="devicedata.localizedmodel">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DeviceData.LocalizedModel

**LocalizedModel** As `String</api/data_types/string>`

> The device model name localized for the language of the device.
>
> This property is read-only.

<div id="devicedata.model">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DeviceData.Model

**Model** As `String</api/data_types/string>`

> The device model name.
>
> This property is read-only.

<div id="devicedata.name">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DeviceData.Name

**Name** As `String</api/data_types/string>`

> The name of the device.
>
> This property is read-only.
>
> This is the name the user gave the device. On iOS, this name appears in Settings \> General \> About \> Name. Per Apple's documentation, the value of this property varies depending on the version of iOS. On iOS 15 and earlier, this will return the user-assigned device name, whereas on iOS 16 and later it will return the generic device name, such as "iPhone" or "iPad."

<div id="devicedata.orientation">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DeviceData.Orientation

**Orientation** As `Orientations<devicedata.orientations>`

> The orientation of the device.
>
> This property is read-only.
>
> This allows you to determine the orientation of the device relative to the Earth. See `Orientations<devicedata.orientations>` for all possible orientations. `MobileScreen.OrientationChanged<mobilescreen.orientationchanged>` event will be called anytime the orientation changes which is a likely place to access the Orientation property. However, you can access it at any other time.
>
> This example displays a message box if the device is face down:
>
> ``` xojo
> If System.Device.Orientation = System.DeviceData.Orientations.FaceDown Then
>   MessageBox("Why are you ignoring me?")
> End If
> ```

<div id="devicedata.proximitymonitoringenabled">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DeviceData.ProximityMonitoringEnabled

**ProximityMonitoringEnabled** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the operating system will update the app to indicate if the device is near the user or not.
>
> To conserve battery power, set this property to `True</api/language/true>` only when you need to check to see if the device is near the user or not and then immediately set it to `False</api/language/false>` so that the device stops using energy to deliver this data to your app.
>
> If the device is near the user, display a message:
>
> ``` xojo
> System.Device.ProximityMonitoringEnabled = True
>
> If System.Device.IsProximityNear Then
>   MessageBox("The device is close to you.")
> End If
>
> System.Device.ProximityMonitoringEnabled = False
> ```

<div id="devicedata.userinterfacetype">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

DeviceData.UserInterfaceType

**UserInterfaceType** As `UserInterfaceTypes<devicedata.userinterfacetypes>`

> Indicates the type of user interface the device provides.
>
> This property makes it easy to determine if the device is a smartphone or a tablet.
>
> This property is read-only.
>
> To get the current type of the user interface, add this to your MobileButton Pressed event
>
> ``` xojo
> Var data As System.DeviceData = System.Device
>
> Select Case data.UserInterfaceType
> Case System.DeviceData.UserInterfaceTypes.Phone
>   MessageBox("Phone")
> Case System.DeviceData.UserInterfaceTypes.Tablet
>   MessageBox("Tablet")
> Case System.DeviceData.UserInterfaceTypes.Unspecified
>   MessageBox("Unspecified")
> End Select
> ```

## Notes

When checking both battery and proximity information, it's important to keep the duration of time in which the app is monitoring this data to a minimum as doing so uses more battery power than usual.

You can get an instance of this class using the `System.Device<system.device>` method. <span class="title-ref">DeviceData</span> exists in the System module, so to access its enumerations, use System.DeviceData.

## Compatibility

|                       |        |
|-----------------------|--------|
| **Project Types**     | Mobile |
| **Operating Systems** | All    |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `System.Device<system.device>` method

</div>
