Class

# MobileMotion

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

## Description

Provides motion updates from the device.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                      | Type                               | Read-Only | Shared |
|-----------------------------------------------------------|------------------------------------|-----------|--------|
| `GravityAccelerationX<mobilemotion.gravityaccelerationx>` | `Double</api/data_types/double>`   | ✓         | ✓      |
| `GravityAccelerationY<mobilemotion.gravityaccelerationy>` | `Double</api/data_types/double>`   | ✓         | ✓      |
| `GravityAccelerationZ<mobilemotion.gravityaccelerationz>` | `Double</api/data_types/double>`   | ✓         | ✓      |
| `Name<mobilemotion.name>`                                 | `String</api/data_types/string>`   | ✓         |        |
| `Pitch<mobilemotion.pitch>`                               | `Double</api/data_types/double>`   | ✓         | ✓      |
| `Roll<mobilemotion.roll>`                                 | `Double</api/data_types/double>`   | ✓         | ✓      |
| `RotationRateX<mobilemotion.rotationratex>`               | `Double</api/data_types/double>`   | ✓         | ✓      |
| `RotationRateY<mobilemotion.rotationratey>`               | `Double</api/data_types/double>`   | ✓         | ✓      |
| `RotationRateZ<mobilemotion.rotationratez>`               | `Double</api/data_types/double>`   | ✓         | ✓      |
| `UpdateInterval<mobilemotion.updateinterval>`             | `Integer</api/data_types/integer>` |           | ✓      |
| `UserAccelerationX<mobilemotion.useraccelerationx>`       | `Double</api/data_types/double>`   | ✓         | ✓      |
| `UserAccelerationY<mobilemotion.useraccelerationy>`       | `Double</api/data_types/double>`   | ✓         | ✓      |
| `UserAccelerationZ<mobilemotion.useraccelerationz>`       | `Double</api/data_types/double>`   | ✓         | ✓      |
| `Yaw<mobilemotion.yaw>`                                   | `Double</api/data_types/double>`   | ✓         | ✓      |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                          | Parameters | Returns                                     | Shared |
|-------------------------------|------------|---------------------------------------------|--------|
| `Handle<mobilemotion.handle>` |            | `Ptr</api/data_types/additional_types/ptr>` |        |
| `Start<mobilemotion.start>`   |            |                                             | ✓      |
| `Stop<mobilemotion.stop>`     |            |                                             | ✓      |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                            | Parameters | Returns |
|---------------------------------|------------|---------|
| `Closing<mobilemotion.closing>` |            |         |
| `Opening<mobilemotion.opening>` |            |         |

## Property descriptions

<div id="mobilemotion.gravityaccelerationx">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.GravityAccelerationX

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

> The X-axis gravity acceleration. Gravity-caused acceleration is constantly downward, and could be used to present something as always "right side up" or other things relating to the ground position.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.

<div id="mobilemotion.gravityaccelerationy">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.GravityAccelerationY

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

> The Y-axis gravity acceleration. Gravity-caused acceleration is constantly downward, and could be used to present something as always "right side up" or other things relating to the ground position.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.

<div id="mobilemotion.gravityaccelerationz">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.GravityAccelerationZ

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

> The Z-axis gravity acceleration. Gravity-caused acceleration is constantly downward, and could be used to present something as always "right side up" or other things relating to the ground position.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.

<div id="mobilemotion.name">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.Name

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

> The name of the control.
>
> This property is read-only.

<div id="mobilemotion.pitch">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.Pitch

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

> A pitch is a rotational position around a lateral axis that passes through the device from side to side.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.

<div id="mobilemotion.roll">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.Roll

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

> A roll is a rotational position around a longitudinal axis that passes through the device from its top to bottom.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.

<div id="mobilemotion.rotationratex">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.RotationRateX

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

> The X-axis rotation rate in radians per second.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.

<div id="mobilemotion.rotationratey">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.RotationRateY

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

> The Y-axis rotation rate in radians per second.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.

<div id="mobilemotion.rotationratez">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.RotationRateZ

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

> The Z-axis rotation rate in radians per second.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.

<div id="mobilemotion.updateinterval">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.UpdateInterval

**UpdateInterval** As `Integer</api/data_types/integer>`

> Set to change how often (in milliseconds) the app should receive updates from the sensors.
>
> This property is `shared</api/language/shared>`.
>
> Shorter intervals result in increased battery usage.

<div id="mobilemotion.useraccelerationx">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.UserAccelerationX

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

> The X-axis user-caused acceleration. User-caused acceleration could be used for detecting things like shakes and other purposeful movement in space.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.

<div id="mobilemotion.useraccelerationy">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.UserAccelerationY

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

> The Y-axis user-caused acceleration. User-caused acceleration could be used for detecting things like shakes and other purposeful movement in space.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.

<div id="mobilemotion.useraccelerationz">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.UserAccelerationZ

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

> The Z-axis user-caused acceleration. User-caused acceleration could be used for detecting things like shakes and other purposeful movement in space.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.

<div id="mobilemotion.yaw">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.Yaw

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

> A yaw is a rotational position around an axis that runs vertically through the device. It is perpendicular to the body of the device, with its origin at the center of gravity and directed toward the bottom of the device.
>
> This property is read-only.
>
> This property is `shared</api/language/shared>`.

## Method descriptions

<div id="mobilemotion.handle">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.Handle

**Handle** As `Ptr</api/data_types/additional_types/ptr>`

> The handle to the underlying native OS control.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is supported for iOS only.
>
> </div>

<div id="mobilemotion.start">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.Start

**Start**

> Start receiving updates from the motion sensors.
>
> This method is `shared</api/language/shared>`.

<div id="mobilemotion.stop">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.Stop

**Stop**

> Stop receiving updates from the motion sensors.
>
> This method is `shared</api/language/shared>`.

## Event descriptions

<div id="mobilemotion.closing">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.Closing

**Closing**

> Called when the control's layout is closing.

<div id="mobilemotion.opening">

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

</div>

<div class="rst-class">

forsearch

</div>

MobileMotion.Opening

**Opening**

> Called when the control's layout is opening.
>
> This is where you typically put initialization code.
>
> This example in the Opening event of a label sets its text to "Hello":
>
> ``` xojo
> Me.Text = "Hello"
> ```

## Notes

On iOS motion updates include both the accelerometer and gyroscope.

Only one <span class="title-ref">MobileMotion</span> object can be created per application for performance reasons. You cannot create a new <span class="title-ref">MobileMotion</span> instance using "New <span class="title-ref">MobileMotion</span>".

You can check and compare the property values at specific points in your code or regularly using a `Timer</api/language/timer>`. To save on battery, you should disable motion detection when it is not needed.

The motion properties return real values only after the Start method has been called. If Start has not been called or Stop has been called, they return 0.

<div class="note">

<div class="title">

Note

</div>

The iOS Simulator does not provide motion data, so you will need to test on an app running on an actual device to see how these property values change.

</div>

## Compatibility

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