Package org.robolectric.shadows
Class ShadowSensorManager
java.lang.Object
org.robolectric.shadows.ShadowSensorManager
@Implements(value=android.hardware.SensorManager.class, looseSignatures=true) public class ShadowSensorManager extends Object
- 
Field SummaryFields Modifier and Type Field Description booleanforceListenersToFail
- 
Constructor SummaryConstructors Constructor Description ShadowSensorManager()
- 
Method SummaryModifier and Type Method Description voidaddSensor(int sensorType, Sensor sensor)Deprecated.UseShadowSensor.newInstance(int)to construct yourSensorand add to theSensorManagerusingaddSensor(Sensor)instead.voidaddSensor(Sensor sensor)Adds aSensorto theSensorManagerprotected ObjectcreateDirectChannel(MemoryFile mem)SensorEventcreateSensorEvent()static SensorEventcreateSensorEvent(int valueArraySize)Creates aSensorEventwith the given value array size, which the caller should set based on the type ofSensorwhich is being emulated.static SensorEventcreateSensorEvent(int valueArraySize, int sensorType)Creates aSensorEventfor the givenSensortype with the given value array size, which the caller should set based on the type of sensor which is being emulated.protected SensorgetDefaultSensor(int type)List<SensorEventListener>getListeners()Returns the list ofSensorEventListeners registered on this SensorManager.List<Sensor>getSensorList(int type)booleanhasListener(SensorEventListener listener)Tests if the sensor manager has a registration for the given listener.booleanhasListener(SensorEventListener listener, Sensor sensor)Tests if the sensor manager has a registration for the given listener for the given sensor.protected booleanregisterListener(SensorEventListener listener, Sensor sensor, int rate)protected booleanregisterListener(SensorEventListener listener, Sensor sensor, int rate, int maxLatency)protected booleanregisterListener(SensorEventListener listener, Sensor sensor, int rate, int maxLatency, Handler handler)protected booleanregisterListener(SensorEventListener listener, Sensor sensor, int rate, Handler handler)voidremoveSensor(Sensor sensor)voidsendSensorEventToListeners(SensorEvent event)Propagates theeventto all registered listeners.protected voidunregisterListener(SensorEventListener listener)protected voidunregisterListener(SensorEventListener listener, Sensor sensor)
- 
Field Details- 
forceListenersToFailpublic boolean forceListenersToFail
 
- 
- 
Constructor Details- 
ShadowSensorManagerpublic ShadowSensorManager()
 
- 
- 
Method Details- 
addSensorDeprecated.UseShadowSensor.newInstance(int)to construct yourSensorand add to theSensorManagerusingaddSensor(Sensor)instead. This method will be removed at some point allowing us to use more of the realSensorManagercode.Provide a Sensor for the indicated sensor type.- Parameters:
- sensorType- from Sensor constants
- sensor- Sensor instance
 
- 
addSensorAdds aSensorto theSensorManager
- 
removeSensor
- 
getDefaultSensor
- 
getSensorList
- 
registerListener@Implementation protected boolean registerListener(SensorEventListener listener, Sensor sensor, int rate, Handler handler)- Parameters:
- handler- is ignored.
 
- 
registerListener@Implementation protected boolean registerListener(SensorEventListener listener, Sensor sensor, int rate, int maxLatency)- Parameters:
- maxLatency- is ignored.
 
- 
registerListener@Implementation(minSdk=19) protected boolean registerListener(SensorEventListener listener, Sensor sensor, int rate, int maxLatency, Handler handler)- Parameters:
- maxLatency- is ignored.
- handler- is ignored
 
- 
registerListener@Implementation protected boolean registerListener(SensorEventListener listener, Sensor sensor, int rate)
- 
unregisterListener
- 
unregisterListener
- 
hasListenerTests if the sensor manager has a registration for the given listener.
- 
hasListenerTests if the sensor manager has a registration for the given listener for the given sensor.
- 
getListenersReturns the list ofSensorEventListeners registered on this SensorManager. Note that the list is unmodifiable, any attempt to modify it will throw an exception.
- 
sendSensorEventToListenersPropagates theeventto all registered listeners.
- 
createSensorEvent
- 
createSensorEventCreates aSensorEventwith the given value array size, which the caller should set based on the type ofSensorwhich is being emulated.Callers can then specify individual values for the event. For example, for a proximity event a caller may wish to specify the distance value: event.values[0] = distance;See SensorEvent.valuesfor more information about values.
- 
createSensorEventCreates aSensorEventfor the givenSensortype with the given value array size, which the caller should set based on the type of sensor which is being emulated.Callers can then specify individual values for the event. For example, for a proximity event a caller may wish to specify the distance value: event.values[0] = distance;See SensorEvent.valuesfor more information about values.
- 
createDirectChannel
 
-