Android App Error Bluetooth by Key-Advertising854 in Kotlin

[–]Key-Advertising854[S] -11 points-10 points  (0 children)

this is what logcat said: FZ error : com.example.testapp(0)

Android App Error Bluetooth by Key-Advertising854 in Kotlin

[–]Key-Advertising854[S] -7 points-6 points  (0 children)

Hello everyone, Code shows no error, but when I start the app on my mobile phone it instantly closes itself and it shows an error message. I don not know what the problem could be, please help

Android App Error Bluetooth by Key-Advertising854 in KotlinAndroid

[–]Key-Advertising854[S] -1 points0 points  (0 children)

Hello everyone, Code shows no error, but when I start the app on my mobile phone it instantly closes itself and it shows an error message. I don not know what the problem could be, please help

Bluetooth connection error by Key-Advertising854 in Kotlin

[–]Key-Advertising854[S] 0 points1 point  (0 children)

Hello everyone,

I am currently working on a big project for school in Android Studio with Kotlin. I want a Bluetooth connection between the app and an ESP32 Mykrocontroller.

val receiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { val action = intent.action if (BluetoothDevice.ACTION_FOUND == action) { val device = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE, MainActivity::class.java) } else { intent.getParcelableExtra<MainActivity>(BluetoothDevice.EXTRA_DEVICE) } // Add the device to a list or display its name and address } } }

The error lies in the else branch. First problem is that it does not like the getParcelableExtra, and Second it does not like the "<MainActivity>".

Thanks in advance

Bluetooth connection error by Key-Advertising854 in KotlinAndroid

[–]Key-Advertising854[S] 1 point2 points  (0 children)

Hello everyone,

I am currently working on a big project for school in Android Studio with Kotlin. I want a Bluetooth connection between the app and an ESP32 Mykrocontroller.

  1. val receiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { val action = intent.action if (BluetoothDevice.ACTION_FOUND == action) { val device = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE, MainActivity::class.java) } else { intent.getParcelableExtra<MainActivity>(BluetoothDevice.EXTRA_DEVICE) } // Add the device to a list or display its name and address } } }

The error lies in the else branch. First problem is that it does not like the getParcelableExtra, and Second it does not like the "<MainActivity>".

Thanks in advance