I have an Activity A. In this activity I have MutableLiveData
,id
. When a button is clicked, I start an Activity B through startActivityForResult()
. After doing some work, I finish Activity B & the onActivityResult()
method is trigger. In this method, I change the value of MutableLiveData()
,id
.
id.value = 5 // ex
But the following code is not triggering:
id.observe(this, Observer {
// do-something if triggered
})
I suspect there is a change of owner when the Activity B is started. What should I do to trigger the observable data from onActivityResult()
?
Please help.