Разработка Android-приложения с передачей значений акселерометра через bluetooth

Суть приложения заключается в том, что при отклонении телефона от начальной позиции по bluetooth должно передаваться направление, в котором был наклонен телефон. (Изначально телефон расположен горизонтально) Помогите понять как считывать данные и передавать их по bluetooth.

Мой activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal">

    <TableRow>

        <TextView
            android:id="@+id/xcoor"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="X Coordinate: " />
    </TableRow>
    // X

    <TableRow>

        <TextView
            android:id="@+id/ycoor"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Y Coordinate: " />
    </TableRow>
    // Y

    <TableRow>

        <TextView
            android:id="@+id/zcoor"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Z Coordinate: " />
    </TableRow>
    // Z

    <SeekBar
        android:id="@+id/SeekBar"
        android:max="10"
        android:layout_marginEnd="25px"
        android:layout_margin="@android:dimen/app_icon_size"
        android:layout_marginRight="@android:dimen/dialog_min_width_major"
        android:layout_height="100px"
        android:progress="1">

    </SeekBar>
    // Ползунок

    <TableRow>

        <TextView
            android:id="@+id/sbcoor"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Значение ползунка: " />
    </TableRow>

</TableLayout>

MainActivity.java

import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;

public class AccelerometerActivity extends Activity implements 
SensorEventListener {
    private SensorManager sensorManager;

TextView xCoor; // declare X axis object
TextView yCoor; // declare Y axis object
TextView zCoor; // declare Z axis object

@Override
public void onCreate(Bundle savedInstanceState){

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    xCoor=(TextView)findViewById(R.id.xcoor); // create X axis object
    yCoor=(TextView)findViewById(R.id.ycoor); // create Y axis object
    zCoor=(TextView)findViewById(R.id.zcoor); // create Z axis object

    sensorManager=(SensorManager)getSystemService(SENSOR_SERVICE);
    // add listener. The listener will be  (this) class
    sensorManager.registerListener(this, 
            sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
            SensorManager.SENSOR_DELAY_NORMAL);


}

public void onAccuracyChanged(Sensor sensor,int accuracy){

}

public void onSensorChanged(SensorEvent event){

    // check sensor type
    if(event.sensor.getType()==Sensor.TYPE_ACCELEROMETER){

        // assign directions
        float x=event.values[0];
        float y=event.values[1];
        float z=event.values[2];

        xCoor.setText("X: "+x);
        yCoor.setText("Y: "+y);
        zCoor.setText("Z: "+z);
    }
}
}

Ответы (0 шт):