com.metaio.sdk
Class SensorsComponentAndroid

java.lang.Object
  extended by com.metaio.sdk.jni.ISensorsComponent
      extended by com.metaio.sdk.SensorsComponentAndroid

public final class SensorsComponentAndroid
extends ISensorsComponent

This class provide an easy interface to the device sensors such as GPS, Gravity etc. It implements ISensorsComponent and can be registered with metaio SDK instance.


Nested Class Summary
static interface SensorsComponentAndroid.Callback
          Callback interface, any class which requires to update based on sensor values can implement this interface and receive new sensor readings when the sensors are updated, the class which implements this interface must register itself with the SensorsComponentAndroid.
 
Field Summary
static boolean isTablet
          true if running on tablet.
static float LM_MINDISTANCE
          Minimum distance to update location (in meters).
static long LM_MINTIME
          Minimum time to update location (in ms).
 
Fields inherited from class com.metaio.sdk.jni.ISensorsComponent
SENSOR_ALL, SENSOR_ATTITUDE, SENSOR_DEVICE_MOVEMENT, SENSOR_GRAVITY, SENSOR_HEADING, SENSOR_LOCATION, SENSOR_NONE, SENSOR_USER_ACCELERATION
 
Constructor Summary
SensorsComponentAndroid(Context context)
          Create sensor manager's object by passing application context and specifying if averaging (smoothing) filter is to be applied to the accelerometer and orientation sensor readings.
 
Method Summary
 Vector3d getGravity()
          The metaio camera-COS is defined as follows: if the device is hold in landscape mode with button to the right and the touch screen facing you, then the positive X-axis points right, the positive Y-axis points up and the positive Z-axis points to you | ________________________________ | | | | | | | ^ Y | | | | | | | | | | | | | | -|--> X | O | | | \\ | | | | \\ | | | | v Z | | | |________________________________| | |________________________________________|This means: If device is hold: => then the gravity vector is: landscape button right => 0 -1 0 landscape button left => 0 +1 0 portrait button down => +1 0 0 portrait button up => -1 0 0 lying horizontal with screen facing up => 0 0 -1 lying horizontal with screen facing down=> 0 0 +1Vector containing the last reading
 float getHeading()
          Heading in degrees
 LLACoordinate getLocation()
          location as LLA coordinates
 Vector3d getOrientationReading()
          Get last orientation sensor reading
 SensorValues getSensorValues()
          Returns the correct device orientation in degrees based on the screen rotation
 void onAccuracyChanged(Sensor sensor, int accuracy)
           
 void onLocationChanged(Location location)
           
 void onProviderDisabled(String provider)
           
 void onProviderEnabled(String provider)
           
 void onSensorChanged(SensorEvent event)
           
 void onStatusChanged(String provider, int status, Bundle extras)
           
 void pause()
          Pause all sensors
 void registerCallback(SensorsComponentAndroid.Callback callback)
          Register callback to receive sensor readings.
 void release()
          Release the sensors' component.
 void resetManualLocation()
          Remove manual location override
 void resume()
          Resume all sensors
 void setManualLocation(LLACoordinate location)
          Set manual LLA location, all updates from LocationManager will be ignore after this call, until resetManualLocation() is called
 int start(int sensors)
           
 int stop()
           
 int stop(int sensors)
           
 
Methods inherited from class com.metaio.sdk.jni.ISensorsComponent
delete, getCPtr, swigReleaseOwnership, swigTakeOwnership
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LM_MINTIME

public static long LM_MINTIME
Minimum time to update location (in ms). The default is 60s.

See Also:
LocationManager#requestLocationUpdates(String, long, float, LocationListener)

LM_MINDISTANCE

public static float LM_MINDISTANCE
Minimum distance to update location (in meters). The default is 1m.

See Also:
LocationManager#requestLocationUpdates(String, long, float, LocationListener)

isTablet

public static boolean isTablet
true if running on tablet. It is initialized in the constructor.

Constructor Detail

SensorsComponentAndroid

public SensorsComponentAndroid(Context context)
Create sensor manager's object by passing application context and specifying if averaging (smoothing) filter is to be applied to the accelerometer and orientation sensor readings. Call SensorsComponentAndroid#open(int) to start the sensors. Register callback through registerCallback(Callback) to receive sensor readings.

Parameters:
context - Application context
filter - true if averaging filter is used, else false
See Also:
SensorsComponentAndroid#open(int), registerCallback(Callback)
Method Detail

registerCallback

public void registerCallback(SensorsComponentAndroid.Callback callback)
Register callback to receive sensor readings. The class must implement all the functions of SensorsComponentAndroid.Callback interface. However, depending on which sensors are opened through SensorsComponentAndroid#open(int), the relevant callbacks will be called at regular intervals.

Parameters:
callback - a class which implements SensorsComponentAndroid.Callback interface
See Also:
SensorsComponentAndroid.Callback

start

public int start(int sensors)
Overrides:
start in class ISensorsComponent
Parameters:
sensors - Sensors to start (see ESENSOR) sensors that are actually started See: ESENSOR, stop

release

public void release()
Release the sensors' component. The component should not be used after this call.


stop

public int stop(int sensors)
Overrides:
stop in class ISensorsComponent
Parameters:
sensors - Sensors to stop (default is all sensors, i.e. SENSOR_ALL) sensors that are actually stopped See: start

pause

public void pause()
Pause all sensors


resume

public void resume()
Resume all sensors


stop

public int stop()
Overrides:
stop in class ISensorsComponent

getLocation

public LLACoordinate getLocation()
Description copied from class: ISensorsComponent
location as LLA coordinates

Overrides:
getLocation in class ISensorsComponent

getOrientationReading

public Vector3d getOrientationReading()
Get last orientation sensor reading

Returns:
a vector (x,y,z) containing orientation reading, x=azimuth, y=pitch, z=roll

getGravity

public Vector3d getGravity()
Description copied from class: ISensorsComponent
The metaio camera-COS is defined as follows: if the device is hold in landscape mode with button to the right and the touch screen facing you, then the positive X-axis points right, the positive Y-axis points up and the positive Z-axis points to you | ________________________________ | | | | | | | ^ Y | | | | | | | | | | | | | | -|--> X | O | | | \\ | | | | \\ | | | | v Z | | | |________________________________| | |________________________________________|This means: If device is hold: => then the gravity vector is: landscape button right => 0 -1 0 landscape button left => 0 +1 0 portrait button down => +1 0 0 portrait button up => -1 0 0 lying horizontal with screen facing up => 0 0 -1 lying horizontal with screen facing down=> 0 0 +1Vector containing the last reading

Overrides:
getGravity in class ISensorsComponent

getHeading

public float getHeading()
Description copied from class: ISensorsComponent
Heading in degrees

Overrides:
getHeading in class ISensorsComponent

getSensorValues

public SensorValues getSensorValues()
Returns the correct device orientation in degrees based on the screen rotation

Overrides:
getSensorValues in class ISensorsComponent
Parameters:
rotationMatrix -
Returns:

onAccuracyChanged

public void onAccuracyChanged(Sensor sensor,
                              int accuracy)

onSensorChanged

public void onSensorChanged(SensorEvent event)

onLocationChanged

public void onLocationChanged(Location location)

onProviderDisabled

public void onProviderDisabled(String provider)

onProviderEnabled

public void onProviderEnabled(String provider)

onStatusChanged

public void onStatusChanged(String provider,
                            int status,
                            Bundle extras)

setManualLocation

public void setManualLocation(LLACoordinate location)
Set manual LLA location, all updates from LocationManager will be ignore after this call, until resetManualLocation() is called

Overrides:
setManualLocation in class ISensorsComponent
Parameters:
location - Manual location

resetManualLocation

public void resetManualLocation()
Remove manual location override

Overrides:
resetManualLocation in class ISensorsComponent