Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. @Override
  2. public void onServicesDiscovered(final BluetoothGatt gatt, int status) {
  3. ................
  4. }
  5.  
  6. @Override
  7. public void onConnectionStateChange(final BluetoothGatt gatt, int status, int newState) {
  8. Log.d(TAG, String.format("BluetoothGattCallback: onConnectionStateChange: status:%d newState:%d", status, newState));
  9. if (newState == BluetoothProfile.STATE_DISCONNECTED) {
  10. Log.d(TAG, "Disconnected from GATT server. Flag = " + connectionStateFlag);
  11. mainThreadHandler.postDelayed(new Runnable() {
  12. @Override
  13. public void run() {
  14. gatt.getDevice().connectGatt(applicationContext, true, callback);
  15. }
  16. }, 2000);
  17. return;
  18. }
  19.  
  20. if (newState == BluetoothProfile.STATE_CONNECTED) {
  21. Log.d(TAG, "Connected to GATT server. Flag = " + connectionStateFlag);
  22. Log.i(TAG, "Connected to GATT server.");
  23. ...
  24. }
  25.  
  26. }
  27.  
  28. @Override
  29. public void onDescriptorWrite(final BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
  30. Log.d(TAG, "onDescriptorWrite()");
  31. }
  32. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement