a noob want to use kitkat to build a project. (helping..!!!)
Hi everyone,
I am doing a simple project with metawear, just want to get the data from accelerometer and do some calculation. So the procedure should be started from:
1: ask user to allow to open the Bluetooth of their smartphone,
2: scan the available devices surrounding.(I want it scanning automatically after allowed and list all devices in a "small window")
3: feedback to user "connected" after tapping the correct one.
4: start to read the data from accelerometer of metawear.
5: convert to be a real acceleration.
7: do some calculation.
Is it correct?
It is my first time to use android studio and I don't have any experience with Java or other computer language. I will appreciate if you can teach me how to write the android code to access it step by step, I am just a newbie so I may need more your patience.
Thanks you so much and have a good day 
This discussion has been closed.

Comments
public class MainActivity extends Activity implements ServiceConnection{
private BluetoothAdapter mBluetoothAdapter;
private static final int REQUEST_ENABLE_BT= 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initializes Bluetooth adapter.
final BluetoothManager bluetoothManager =
(BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothAdapter = bluetoothManager.getAdapter();
if (!bluetoothManager.getAdapter().isEnabled()) {
final Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
}
//bind with metawear
getApplicationContext().bindService(new Intent(this,MetaWearBleService.class),
this, Context.BIND_AUTO_CREATE);
}
public void setBtDevice(BluetoothDevice device) {
mwController= mwService.getMetaWearController(device);
mwController.setRetainState(false);
mwController.addDeviceCallback(new MetaWearController.DeviceCallbacks() {
@Override
public void connected() {
accelCtrllr= ((Accelerometer) mwController.getModuleController(Module.ACCELEROMETER));
accelCtrllr.enableXYZSampling().withFullScaleRange(Accelerometer.SamplingConfig.FullScaleRange.FSR_2G)
.withOutputDataRate(Accelerometer.SamplingConfig.OutputDataRate.ODR_200_HZ);
Toast.makeText(getActivity(), R.string.toast_connected, Toast.LENGTH_SHORT).show();
}
@Override
public void disconnected() {
Toast.makeText(getActivity(), R.string.toast_disconnected, Toast.LENGTH_SHORT).show();
}
}).addModuleCallback(new Accelerometer.Callbacks() {
@Override
public void receivedDataValue(short x, short y, short z) {
Log.i("MainActivity", String.format(Locale.US, "(%.3f, %.3f, %.3f)",
x / 1000.0, y / 1000.0, z / 1000.0));
accelCtrllr.startComponents();
}
});
mwController.connect();
}
public void receivedDataValue(short x, short y, short z) {
Log.i("MainActivity", String.format(Locale.US, "(%.3f, %.3f, %.3f)",
x / 1000.0, y / 1000.0, z / 1000.0));
accelCtrllr.startComponents();
}
addModuleCallback(new Accelerometer.Callbacks() {
@Override
public void receivedDataValue(short x, short y, short z) {
//Here create a while loop for storing till it stop
}
.addModuleCallback(new Accelerometer.Callbacks() {
@Override
public void receivedDataValue(short x, short y, short z) {
do {
accX[i] = x/1000.00;
accY[i] = y/1000.00;
accZ[i] = z/1000.00;
i = i + 1;
} while(//Condition start-logging and stop-exit);
}
.addModuleCallback(new Accelerometer.Callbacks() {@Override
public void receivedDataValue(short x, short y, short z) {AcceleLength.add(z);// add data}
.addModuleCallback(new GPIO.Callbacks() {@Override
public void pinChangeDetected ( byte pin, byte state) {
if (state == 0) {
accelCtrllr.startComponents();
} else {
accelCtrllr.stopComponents();