In my android,OnapplicationQuit seems not working,I have put a call in that method,but not getting excecuted.plz help
Under what circumstance are you expecting it to run? Mobile apps don’t generally do controlled shutdowns; they just quietly live in the background forever until the OS decides to forcibly kill them.
Post the source code. Is it inside of a MonoBehaviour class? Is that class actually instantiated in your scene? What is the function doing that allows you to know that it is not being called during quit? What is the class doing that lets you know the class is working correctly except for this function?
Everything that @Antistone said above is spot-on… but let me add you can do this if you just want notification that the app went into background:
Again, as Anti noted above, gotta be in a monobehavior, gotta be on an enabled GameObject in the current scene when you leave the app, so it’s often a great use for a DontDestroyOnLoad() that you ONLY put in your first scene, and then never return to the first scene again, or else do the whole UnitySingleton pattern (google for that one).
OnApplicationQuit only exists to make you waste hours trying to figure out why the event doesn’t fire on Android. Would be great if Unity warned us in the docs.
support
https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationQuit.html
Not sure why we’re necroing a post just to comment “support” when the docs clearly mention what happens “on mobile platforms”