There is CheckBox with following code:
CheckBox cb = (CheckBox)findViewById(R.id.freezer); cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChan
Since you know how to get the current orientation, just write
if(isChecked){ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); }