I've been recently trying out Android's in-app-update API here https://developer.android.com/guide/playcore/in-app-updates and calling appUpdateManager.completeUpdate()
this method after successfully downloading the update seems to work, if I stay put on the view (fragment / activity) or rest my app in the background, but if I move to my app's other view it crashes, This is similar to Snackbar implementation trying to find views when the update fails or is cancelled but I move to a different fragment / activity. Is there a more efficient way to handle this globally throughout the app? It's really hard to debug it since you need an internal production build to test it out.
A similar solution I can think of is how toast behaves, even if you kill the view / activity, the toast will still show to the user, but I still want to use Snackbar and also need to call completeUpdate() if download is finished, where my user still has the freedom to browse the app and not crash.
Snackbar
needsCoordinatorLayout
to be shown (most common usage), it's just aView
, so when you want to show it, you need active GUI on foreground. when you start app update and move somewhere whereSnackbar
can't be shown then yourException
occursToast
is kind of system service with possibility to be shown on top of everything, completely different approach. for showingToast
you need onlyContext