getting data from non activity class implementing sensoreventlistener
<p>Sorry for the stupid question but i'm new to android and i can't find a solution.</p>

<p>In brief, i have a class with a sensoreventlistener and i want to use data received from sensors in the main activity. I tried but with no success
Here my code:</p>

<pre><code>public class Lis{

SensorManager MagSensorManager;
SensorManager ACCSensorManager;
Sensor magnetometer;
Sensor Accelerometer;
Callback cb =null;
float [] magvec =new float[3];
float [] lin =new float[3];





Lis(Context context, Callback cb)
{

    MagSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    ACCSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);

    ACCSensorManager.registerListener(listener,Accelerometer, SensorManager.SENSOR_DELAY_GAME);
    MagSensorManager.registerListener(listener,magnetometer, SensorManager.SENSOR_DELAY_GAME);
    this.cb=cb;
}
SensorEventListener listener = new SensorEventListener() {

    public void onAccuracyChanged(Sensor sensor, int accuracy) {
    // TODO Auto-generated method stub

}
public void onSensorChanged(SensorEvent event) {

    switch (event.sensor.getType())
    {
    case Sensor.TYPE_MAGNETIC_FIELD:
         magvec = event.values.clone();
         break;
    case Sensor.TYPE_LINEAR_ACCELERATION:
         lin = event.values.clone();
         break;

    }



            SensorManager.getRotationMatrix(Ri, I, lin, magnetic);
        SensorManager.getOrientation(Ri, orientat);
                orientat[0] = (float) Math.toDegrees(orientat[0]);
            cb.azvalue(orientat[0]);

}
}

};



 public interface Callback {
        void azvalue(float azim);

    }
</code></pre>

<p>}</p>

<hr>

<p>public class MainActivity extends Activity implements Lis.Callback{</p>

<pre><code>    TextView tbX;

    Lis listen;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tbX = (TextView)findViewById(R.id.textView1);
        listen=new Lis(this,this);
    }       


    @Override
    protected void onPause() {
        super.onPause();

    }
    public void azvalue(float azim)
    {
        tbX.setText("azimuth"+azim);
    }
</code></pre>

<p>}</p>

<p>Where am i wrong? If i try to run the apk i get only the default text from tbX textview and not "azimuth"+value.</p>

<p>Thanks in advance.</p>
