I need to pass a value from my main Activity to a custom View.
In the main activity I have a SensorEventListener so I'm continuosly listening to the light sensor. In the onSensorChanged() method I read the value, and I need to send this value every time it changes to my custom View.
I don't know which is the best way to achive this.
UPDATE --
Method refered to SensorEventListener on main activity:
@Override
public void onSensorChanged(SensorEvent event) {
float lumnes = event.values[0];
GaugeView.setHandTarget(lumnes);
}
Method I have to send values to in custom view:
public void setHandTarget(float temperature) {
if (temperature < minDegrees) {
temperature = minDegrees;
} else if (temperature > maxDegrees) {
temperature = maxDegrees;
}
handTarget = temperature;
handInitialized = true;
invalidate();
}
I cannot use static references cause then I cannot call invalidate()