0

When calling Activity#recreate() from a Checkbox's OnCheckChanged callback, I get a black screen. When calling from a Button's OnClick event callback, it works fine. Any reasons, code using butterknife below (same without butterknife)?

@OnCheckChanged(R.id.check_box)
void checkChanged(CheckBox cb){
 recreate(); // shows black screen
}

@OnClick(R.id.button)
void checkChanged(Button btn){
 recreate(); // works as expected
}
aprofromindia
  • 1,111
  • 1
  • 13
  • 27
  • Please post some code – salih kallai Aug 18 '16 at 18:24
  • 3
    I would assume that since CheckBox.onCheckedChange() is invoked even when the value is set programmatically (not just from user interaction) this checkChanged listener is probably being invoked whenever the activity is created, which then creates an infinite loop of activity recreations. You could verify by adding a log statement before the call to "recreate()" and see if you get constant output. – Kevin Coppock Aug 18 '16 at 18:46
  • See https://stackoverflow.com/a/52331896 – Bruno Bieri Feb 04 '20 at 08:48

0 Answers0