There is no means to do that, sorry.
Either the activity needs the data, or it does not. If it does, then the activity-scoped
ViewModel is a good thing, and keeping it alive is a good thing.
If it does not, then the next question is: how big is the unique data (i.e., data that is not already referenced elsewhere, such as in a cache)? If it is large — say, hundreds of KB — then perhaps it is something that you need to worry about. Conversely, if the data is small, I would not worry about it unless you were encountering some specific problems.
But, if in the end you conclude that you do need to do something, I know of only three options:
Do something other than a shared viewmodel. For example, there is the
FragmentResult system. It’s only in alpha, and I have not used it, but it is an option for passing data between fragments.
See if you can find a tighter-scoped
ViewModelStoreOwner. For example, the Navigation component allows you to scope a
ViewModel to a navigation graph, so perhaps you could arrange for a nested navigation graph for these two fragments.
Something that knows about when these fragments come and go (probably the activity) tells the viewmodel to flush its caches when both of those fragments are gone.