@@ -591,10 +591,19 @@ private void invokeConnectToBluetoothDevice() {
591
591
return ;
592
592
}
593
593
594
+ connectToBluetooth ();
595
+ }
596
+
597
+ private void connectToBluetooth () {
598
+ String deviceName = prefs .getString (
599
+ BluetoothSettingsFragment .PREFERENCE_KEY_BLUETOOTH_DEVICE_NAME , "" );
600
+ String hwAddress = prefs .getString (
601
+ BluetoothSettingsFragment .PREFERENCE_KEY_BLUETOOTH_HW_ADDRESS , "" );
602
+
594
603
Toast .makeText (getApplicationContext (), getResources ().getString (R .string .info_bluetooth_try_connection ) + " " + deviceName , Toast .LENGTH_SHORT ).show ();
595
604
setBluetoothStatusIcon (R .drawable .ic_bluetooth_searching );
596
605
597
- if (!openScale .connectToBluetoothDevice (deviceName , hwAddress , callbackBtHandler )) {
606
+ if (!OpenScale . getInstance () .connectToBluetoothDevice (deviceName , hwAddress , callbackBtHandler )) {
598
607
setBluetoothStatusIcon (R .drawable .ic_bluetooth_connection_lost );
599
608
Toast .makeText (getApplicationContext (), deviceName + " " + getResources ().getString (R .string .label_bt_device_no_support ), Toast .LENGTH_SHORT ).show ();
600
609
}
@@ -902,7 +911,7 @@ public void onRequestPermissionsResult(int requestCode, String permissions[], in
902
911
903
912
if (allGranted ) {
904
913
Timber .d ("All Bluetooth permissions granted" );
905
- invokeConnectToBluetoothDevice ();
914
+ connectToBluetooth ();
906
915
} else {
907
916
Timber .d ("At least one Bluetooth permission was not granted" );
908
917
Toast .makeText (this , R .string .permission_not_granted , Toast .LENGTH_SHORT ).show ();
0 commit comments