I can't invoke setValue on a background thread and keep observe functionality

104 Views Asked by At

java.lang.IllegalStateException: Cannot invoke setValue on a background thread

I get the above error when I try to use setvalue:

data.setValue(arrayListLogReturn);

I understand that I can change this to postvalue, but then I lose observe functionality on the livedata.

data.postValue(arrayListLogReturn);

My question is how do I keep observe functionality and update the value ? Any help would be appreciated.

0

There are 0 best solutions below