I have a service where I declare this liveData
public static final MutableLiveData<String> newMessageDispatcher = new MutableLiveData<>();
Inside the main activity I cannot do newMessageDispatcher.observe(myActivity, newMessageObserver)
because my activity do not extends AppCompatActivity
so it's not a LifecycleOwner
.
Now If I do newMessageDispatcher.observeForever(newMessageObserver)
, what will happen when the user will close the app (by swiping up in the recent apps window), so closing the main activity without calling newMessageDispatcher.removeObserve(newMessageObserver)
? Does the observer will be successfully removed or do I absolutely need to call newMessageDispatcher.removeObserve(newMessageObserver)
?