How to Relaunch Your Unity Android Application
A couple weeks back I was implementing the latest Unity Analytics (Beta) service into Unity Pomodoro.
And something that was a bit odd, was that there was no simple way to toggle the service off during run-time. The only way around this, I found...was not to initialize the service on launch. As a result I was forced to re-launch/restart the application process entirely and prevent the service from being initialized in the first place when users wanted to turn off Unity analytics during run-time. (...which requires a restart)
Here is what that relaunch workaround looked like.
Luckily, it seems like as of Analytics - Version 4.0 we can now enable/disable the service at runtime:
Added ability to disable and re-enable the Analytics SDK
However, if you're looking for a way to close/kill the current Android process of the application and relaunch it without the need for any user input, here's the method to do that:
This will likely break in the future but its managed to serve my needs for Android 11 using Unity 2020.3
Best of luck!