Enlève les boutons « (dé)connecter »

This commit is contained in:
Louis-Guillaume DUBOIS 2017-06-02 18:31:40 +02:00
parent b5d22d7b4d
commit 8202921a6d
No known key found for this signature in database
GPG key ID: 96472D986598B31E
2 changed files with 13 additions and 1 deletions

View file

@ -37,6 +37,8 @@ import java.util.List;
import java.util.StringTokenizer;
import java.util.UUID;
import static java.lang.Thread.sleep;
/**
* Service for managing connection and data communication with a GATT server hosted on a
* given Bluetooth LE device.
@ -318,7 +320,12 @@ public class BluetoothLeService extends Service {
enabled ? BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE
: BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE
);
while (!mBluetoothGatt.writeDescriptor(descriptor)) ;
try {
while (!mBluetoothGatt.writeDescriptor(descriptor))
sleep(500);
} catch (Exception e) {
e.printStackTrace();
}
}
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
}

View file

@ -144,6 +144,7 @@ public class SimpleDetailActivity extends Activity {
mBluetoothLeService = null;
}
/*
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.gatt_services, menu);
@ -156,16 +157,19 @@ public class SimpleDetailActivity extends Activity {
}
return true;
}
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
/*
case R.id.menu_connect:
mBluetoothLeService.connect(mDeviceAddress);
return true;
case R.id.menu_disconnect:
mBluetoothLeService.disconnect();
return true;
*/
case android.R.id.home:
onBackPressed();
return true;
@ -173,6 +177,7 @@ public class SimpleDetailActivity extends Activity {
return super.onOptionsItemSelected(item);
}
private void updateConnectionState(final int resourceId) {
runOnUiThread(new Runnable() {
@Override