check bluetooth enabled

master
Zhengyu Peng 3 years ago
parent 36d9080fc9
commit dc5d349db6

@ -124,7 +124,6 @@ class MainActivity : AppCompatActivity() {
if (bluetoothAdapter != null) { if (bluetoothAdapter != null) {
if (!bluetoothAdapter.isEnabled) { if (!bluetoothAdapter.isEnabled) {
alertDialog(ERROR_BLUETOOTH_DISABLED) alertDialog(ERROR_BLUETOOTH_DISABLED)
}
} else { } else {
if (btConnectPermission && btScanPermission) { if (btConnectPermission && btScanPermission) {
val serverIntent = Intent(this, DeviceListActivity::class.java) val serverIntent = Intent(this, DeviceListActivity::class.java)
@ -134,6 +133,7 @@ class MainActivity : AppCompatActivity() {
} }
} }
} }
}
if (tabLayout.selectedTabPosition == 0) { if (tabLayout.selectedTabPosition == 0) {
ipLayout.visibility = View.VISIBLE ipLayout.visibility = View.VISIBLE
@ -176,7 +176,6 @@ class MainActivity : AppCompatActivity() {
if (bluetoothAdapter != null) { if (bluetoothAdapter != null) {
if (!bluetoothAdapter.isEnabled) { if (!bluetoothAdapter.isEnabled) {
alertDialog(ERROR_BLUETOOTH_DISABLED) alertDialog(ERROR_BLUETOOTH_DISABLED)
}
} else { } else {
if (btConnectPermission && btScanPermission) { if (btConnectPermission && btScanPermission) {
saveSharedPref() saveSharedPref()
@ -189,6 +188,7 @@ class MainActivity : AppCompatActivity() {
alertDialog(ERROR_NO_PERMISSION) alertDialog(ERROR_NO_PERMISSION)
} }
} }
}
} else { } else {
alertDialog(ERROR_NO_DEVICE) alertDialog(ERROR_NO_DEVICE)
} }
@ -242,7 +242,6 @@ class MainActivity : AppCompatActivity() {
} else if (requestCode == BLUETOOTH_SCAN_CODE) { } else if (requestCode == BLUETOOTH_SCAN_CODE) {
btScanPermission = true btScanPermission = true
} }
} }
} }

Loading…
Cancel
Save