// OnCreate, called once to initialize the activity. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); messages = (TextView) findViewById(R.id.messages); adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter == null) { // Device does not support Bluetooth } if (!adapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, 1); } connectButton = (Button) findViewById(R.id.connectButton); connectButton.setVisibility(View.INVISIBLE); // connectButton.setBackgroundColor(0xffffff00); // connectButton.setText("Start Scanning"); beginScan(); animatedCircleLoadingView = (AnimatedCircleLoadingView) findViewById(R.id.circle_loading_view); animatedCircleLoadingView.startIndeterminate(); // connectButton.setOnClickListener(new View.OnClickListener() { // public void onClick(View v) { // // beginScan(); // // } // }); }
// Called when a remote characteristic changes (like the RX characteristic). @Override public void onCharacteristicChanged( BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { super.onCharacteristicChanged(gatt, characteristic); vitaminValue = characteristic.getStringValue(0); Intent intent = new Intent(MainActivity.this, ResultsActivity.class); intent.putExtra(EXTRA_MESSAGE, vitaminValue); startActivity(intent); animatedCircleLoadingView.stopOk(); presentValue(); }