OnApplicationQuit is called when you explicitly call Application.Quit() which is usually done by either back button or an exit dialogue.
void Update ()
{
if (Input.GetKeyDown(KeyCode.Escape)
{
Application.Quit();
}
}
OnApplicationQuit will not be called when user press Home button or task list button and closes your game afterward, a phone battery die or game crash. none of the above.
To do any operation on user exit, I recommend implementing OnFocus or OnPause which happens when user press home button or tasks list on android.
remember if user does tasks list and immediately close your game any write on disk operation will halt and results in unfinished and corrupted save file. and next time you load that file, it fails to read the stream and throws exception. you can prevent that by specifying a temporary name for your save file during the write operation and when it's finished replace the temporary file with the save file. an extra disk operation but a fail safe, or categorize your save file into chunks of data less than 10kb, by doing that no matter how fast user goes from task list button to close all button, there was enough time to write 10kb to disk.
other alternative to that is creating a service using this
or create another activity beside unity activity and set a process name for it too in AndroidManifest.xml
https://answers.unity.com/questions/780406/androidunity-launching-activity-from-unity-activit.html
void StartPackage(string package){
AndroidJavaClass activityClass;
AndroidJavaObject activity, packageManager;
AndroidJavaObject launch;
activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
activity = activityClass.GetStatic<AndroidJavaObject>("currentActivity");
packageManager = activity.Call<AndroidJavaObject>("getPackageManager");
launch = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage",package);
activity.Call("startActivity",launch);
}
and in AndroidManifest.xml
<activity
android:name=".YourActivity"
android:process=".YourActivity" />