onapplicationquit() function is not working with unity 4.6.3 (android)

Hi Guys

i am using unity 4.6.3 , on that version onapplicationquit() function is not working , i want to save playerprefs in that function but it is not save the values and game state and also use dontdestroyonload() function


using UnityEngine;

using System.Collections;

using System;

public class scriptss : MonoBehaviour
{

private void OnApplicationQuit ()
{
	PlayerPrefs.SetInt ("chart", 0);
	PlayerPrefs.Save ();
}

}

OnApplicationQuit() is NOT guaranteed to be called on Android. You can read more about that here, but Android activities that have been paused are NOT guaranteed to always give a Quit callback. Due to this design, many developers instead save crucial data at other points (scene loads, game over screens, checkpoint, etc). If you need this precise data on any application suspension (with a quit possibly ahead), a popular alternative is OnApplicationPause().

Instead of what you have, try this:

private void OnApplicationPause()
 {
     PlayerPrefs.SetInt ("chart", 0);
     PlayerPrefs.Save ();
 }

#imageHanoble there no difference in private and without private is work as same

OnApplicationQuit() working on Unity editor but not working on android build thats my question

OnApplicationQuit must not be private, in order for Unity to call the function when it closes the application. Simply remove the private keyword in front of void OnApplicationQuit().