Hi @yanghouze , since we are an Android derived platform it is good practice to follow best practices for Android when it comes to the application lifecycle. Waiting for OnApplicationQuit on Android is not recommended but rather you should treat OnPause (or OnApplicationPause(bool) in Unity) as if it will close the application.
You can see here in Android's onDestroy method (which is mapped to Unity's OnApplicationQuit)
Note: do not count on this method being called as a place for saving data! For example, if an activity is editing data in a content provider, those edits should be committed in either
onPause()
oronSaveInstanceState(Bundle)
, not here.
This should be fairly straightforward for a non-networked application as you should be saving / journaling whatever app data you need during pause. If you are doing back-grounded work it can be a little more complex but assuming you are running in the background I would make some co-routine off the main loop and manage the connection that way.
Does that help?