Android Studio/Java: error: incomparable types: Switch and boolean

i'm kinda new to Android Studio, and Java in general...

Quick recap of my project:

Bluetooth controlled car, from smartphone til arduino. Thats kinda it.

My code is a mix of different codes + my own. But i got the following error, when trying to make a switch that (right now turns a LED on and off) will start and stop the car.

error: incomparable types: Switch and boolean

Maybe i just dont understand if statements. This is the section where the error occurred:

Switch on_off_switch = (Switch) findViewById(;

on_off_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {



Read More »

By: StackOverFlow - Thursday, 8 November

Related Posts