I have a way to connect a Bluetooth Device. Now I'm trying to show a popup dialog that shows when the app has no connection with the Bluetooth Device.
I already have the popup dialog, I only need to create a IF statement that checks if the app has a connection with a Bluetooth Device, if true: it doesn't show the popup dialog, if no: it shows the dialog and tries to reconnect with the Bluetooth Device.
This is the popup:
val bluetoothDialog = AlertDialog.Builder(this@MainActivity)
val bluetoothView = layoutInflater.inflate(R.layout.bluetoothdialog, null)
bluetoothDialog.setTitle("Bluetooth Connection Status")
bluetoothDialog.setView(bluetoothView)
bluetoothDialog.setPositiveButton("OK") { _,_ ->}
bluetoothDialog.setCancelable(false)
testbutton.setOnClickListener{
if(connection == true){
"Don't show popup"
}else{
bluetoothDialog.show()
"and Retry connection"
}
}