DeviceInfo

Since: BlackBerry 10.0.0

#include <bb/device/DeviceInfo>

To link against this class, add the following line to your .pro file: LIBS += -lbbdevice

Provides access to information about the current state of the device.

The DeviceInfo class provides access to information about the current state of the device, such as the orientation in which the device is currently being held and the activity state of the device.

Instances of this class can be used to monitor the activity state of the device, which can be used to determine if the end user can interact with the device.

If the device is active, then the user is able to interact with it. This implies that the display is enabled, but does not imply anything about the lock state of the device. A user is still able to interact with a locked device, to unlock it. That is, an active device may be unlocked, screen-locked, or password-locked.

If the device is inactive, then the user is not able to interact with it. This implies that the display is disabled. Further, the device may be screen-locked or password-locked, and may even be in standby mode.

Also note that this is the device activity state. The state of the requesting process (fullscreen, thumbnailed, or invisible) has no effect on the result.


Overview

Signals Index

voidactivityStateChanged (bb::device::UserActivityState::Type activityState)
voidorientationChanged (bb::device::DeviceOrientation::Type orientation)
voidorientationValidChanged (bool isValid)

Properties

bb::device::UserActivityState::Type activityState[read-only]

The activity state of the device.

Since:

BlackBerry 10.2.0

bb::device::DeviceOrientation::Type orientation[read-only]

The current orientation of the device.

To interpret the value, see bb::device::DeviceOrientation.

Since:

BlackBerry 10.0.0

bool orientationValid[read-only]

The validity of the orientation value.

The orientation is valid if a valid value has been received from the underlying sensor, otherwise it is not valid.

Since:

BlackBerry 10.3.0

Public Functions

DeviceInfo (

Constructs a DeviceInfo object.

Constructs a DeviceInfo object from which may be retrieved information about the device.

Parameters
parent

If not 0, the supplied parent will be responsible for deleting this instance.

Since:

BlackBerry 10.0.0

virtual~DeviceInfo ()

Destructor.

Since:

BlackBerry 10.0.0

bb::device::UserActivityState::Type activityState ()

Returns the current user activity state.

Return:

The current user activity state. See bb::device::UserActivityState for a list of possible states.

Since:

BlackBerry 10.2.0

bool isOrientationValid ()

Returns whether the current orientation is valid.

When a DeviceInfo instance is created, the underlying sensor backend is started. In certain instances this startup may take some time, and so a default value of bb::device::DeviceOrientation::TopUp will be returned until a value is supplied by the underlying sensor.

Any time that the orientationChanged signal is emitted results in a valid value.

Return:

True if the value returned by orientation() is valid, false otherwise.

Since:

BlackBerry 10.3.0

bb::device::DeviceOrientation::Type orientation ()

Retrieves the current orientation of the device.

This function lets you retrieve the current orientation of the device. To interpret the result, see bb::device::DeviceOrientation.

In order to determine whether or not the orientation returned from this method is valid, you should check the value returned by isOrientationValid.

The value returned from this function will be bb::device::DeviceOrientation::TopUp until the underlying sensor has provided a value. Attaching to either the orientationChanged or the orientationValidChanged signals should inform you when the default value is no longer being returned.

Return:

Returns the current orientation of the device as specified in bb::device::DeviceOrientation.

Since:

BlackBerry 10.0.0

Signals

void activityStateChanged (

Emitted when the user activity state has changed.

Parameters
activityState

The new activity state of the device.

Since:

BlackBerry 10.2.0

void orientationChanged (

Emitted when the orientation of the device has changed.

This notification is independent of the orientation of the display changing. Specifically, this signal will still be emitted as the device is tilted, even if an application has locked the screen rotation.

Parameters
orientation

The new orientation the device has assumed.

Note:

Do not use this signal to control any aspect of your UI layout. Use the appropriate orientation signals supplied by the Cascades UI framework.

Since:

BlackBerry 10.0.0

void orientationValidChanged (
  • boolisValid)

Emitted when the validity of the orientation value has changed.

Parameters
isValid

Whether the current orientation value is valid.

Since:

BlackBerry 10.3.0

Last modified: 2014-06-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus