How send back to the MainActivity the sensor results?

204
February 11, 2018, at 08:23 AM

Well, I have a class Sesnsores, where I implement the SensorEventListener and register it. I need to send back to the MainActivity de values of X, Y and Z, but what I'm trying doesn't work.

I create this interface in the sensores class:

public interface SensorListener {
    void onSensorChanged(float x, float y, float z);
}

Then, I create an atribute with this:

private SensorListener sListener;

In the SensorEventListener, I use the interface to send the results:

private SensorEventListener sel = new SensorEventListener() {
    @Override
    public void onSensorChanged(SensorEvent sensorEvent) {
        sListener.onSensorChanged(sensorEvent.values[0], sensorEvent.values[1], sensorEvent.values[2]); ;
    }
    @Override
    public void onAccuracyChanged(Sensor sensor, int i) {
    }
};

Obviously, I implement the interface in the MainActivity and use it like this:

@Override
public void onSensorChanged(float x, float y, float z) {
    etEjeX.setText(String.valueOf(x));
    etEjeY.setText(String.valueOf(y));
    etEjeZ.setText(String.valueOf(z));
}

What am I doing wrong? The application is minimized as soon as I open it and it does not let me do anything.

Rent Charter Buses Company
READ ALSO
Is it possible to build an APK on a device?

Is it possible to build an APK on a device?

Is it possible to build APK from source with in an android phone?

177
IMEI Checker API [on hold]

IMEI Checker API [on hold]

I have searched alot for IMEI Checker API , but best one i found is this:http://wwwimei

190
Aapt2 error : check logs for details

Aapt2 error : check logs for details

Please give me solution of this problem This error is occurred when I create new activityR

561
Firebase intraday-events in Data Studio from BigQuery

Firebase intraday-events in Data Studio from BigQuery

We have an iOS-app and an Android-app where Firebase-events are sent to Google BigQuery and displayed in Google Data Studio

218