I have an android watch app that i am building. Disclaimer, I'm a Java engineer with some early experience in android, say 10 years ago so I'm not overly familiar with Kotlin or Jetpack Compose.
I've written an android wear app to keep track of scores in a game as a referee and I'm running into problems persisting data when the app is dismissed. As it stands I've implemented a ViewModel and it's correctly wired into the UI to keep track of the scores / state as the app is open. However, because the swipe to dismiss gesture kills the app, if this happens accidentally in a game it can be disastrous as the tallied score is lost. I'm unable to get android to prevent the swipe gesture.
I've tried umpteen online tutorials but I can't find anything that works. Essentially, In my head I reason about this as: I want to wire into the onDestroy callback to persist data to the device, In onResume I want to read the data from the device and put it into the viewModel so the app can remember it's state. If anyone has used a stopwatch app on a wear device, the state is persisted regardless of dismissal or not. How can I do this in my app? The codebase (Small that it is) is located https://github.com/mcgowanb/refscorekeeper.