DeviceOrientationRequest.Builder

  • DeviceOrientationRequest.Builder is a builder for creating DeviceOrientationRequest objects.

  • You can construct a new Builder by providing a sampling period in microseconds or by copying values from an existing DeviceOrientationRequest.

  • The build() method creates the final DeviceOrientationRequest object.

  • The setSamplingPeriodMicros() method sets the desired interval for device orientation updates, with a recommended default of 20,000 microseconds.

  • Setting a negative or Long.MAX_VALUE interval for sampling period will throw an IllegalArgumentException.

public static final class DeviceOrientationRequest.Builder extends Object

A builder for DeviceOrientationRequest.

Public Constructor Summary

Builder(long samplingPeriodMicros)
Constructs a new builder, requiring to provide a samplingPeriodMicros.
Builder(DeviceOrientationRequest src)
Constructs a new builder with values copied from a given DeviceOrientationRequest.

Public Method Summary

DeviceOrientationRequest
DeviceOrientationRequest.Builder
setSamplingPeriodMicros(long samplingPeriodMicros)
Sets the requested period (in microseconds) for device orientation updates.

Inherited Method Summary

Public Constructors

public Builder (long samplingPeriodMicros)

Constructs a new builder, requiring to provide a samplingPeriodMicros.

public Builder (DeviceOrientationRequest src)

Constructs a new builder with values copied from a given DeviceOrientationRequest.

Public Methods

public DeviceOrientationRequest build ()

Builds a new DeviceOrientationRequest.

public DeviceOrientationRequest.Builder setSamplingPeriodMicros (long samplingPeriodMicros)

Sets the requested period (in microseconds) for device orientation updates.

The device orientation client will attempt to obtain updates for your application at least at the specified interval. Therefore, it has a direct influence on the amount of power used by your application. By default, we recommend a sampling period of 20_000 microseconds (for example, 50Hz).

This interval is not guaranteed to be used. Your app may not receive updates at all (if no device orientation sources are available). It may also receive them faster or slower than requested (for example if other applications are requesting device orientation at a faster interval, or a sampling rate is not supported by the device).

Throws
IllegalArgumentException if the interval is less than zero or equal to Long.MAX_VALUE