title: Customizing Android BluetoothLeGatt example and send data via BLE
body: <p>I have to say at first that i am new to android programming. I am trying to send simple data (a short string) to a BLE peripheral device via Android. Therefore i customized the BluetoothLeGatt example from</p>
  
  <p><a href="http://developer.android.com/samples/BluetoothLeGatt/project.html" rel="nofollow">http://developer.android.com/samples/BluetoothLeGatt/project.html</a></p>
  
  <p>I replaced the Gatt Services List in the gatt_services_characteristics.xml with a text field for incoming data and below a EditText and a "send" button. The code is the following:</p>
  
  <pre><code>&lt;TextView android:id="@+id/gatt_services_list"
              android:layout_width="match_parent"
              android:layout_height="250dp" /&gt;
      &lt;EditText android:id="@+id/sendText"
          android:layout_width="match_parent"
          android:layout_height="50dp"
          android:layout_margin="10dp"
          android:layout_below="@id/gatt_services_list"/&gt;
      &lt;Button
          android:id="@+id/sendButton"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:text="SEND"
          android:onClick="sendData"/&gt;
  </code></pre>
  
  <p>I also commented out the function displayGattServices(List gattServices) in DeviceControlActivity.java and wrote a function for the button click as below:</p>
  
  <pre><code>public void sendData(View v) {
      value = textField.getText().toString();
      byte [] strBytes = value.getBytes();
  
      mGattServicesList.setText(text + "\n&gt;" + value);
      text = text + "\n&gt;" + value;
  
      clearUI();
  }
  </code></pre>
  
  <p>I now want to implement a simple way to send the data typed in the EditText. The data just shall be shown in a terminal.</p>
  
  <p>I searched for a solution, but i didn't fully understand the concept of the Gatt Characteristic which i am afraid i have to use for this. I am programming with Android Studio 1.4.1 and using API 18 and higher.</p>
  
  <p>How can i send the data in an easy way?</p>
  
  <p>Thanks in advance</p>