- Home /
Is there a way to force OnApplicationPause method?
Hi Everyone.
I'm currently working in an android proyect, and my problem is this, when I minimize the application (with home button or lock), the application still running in background (the media volume still present when I press volume keys in my home screen) and this reduce the memory of the phone and crash after a while or when I open more applications.
I set my time in 0 (UnityEngine.Time.timeScale = 0.0f), to stop the game (the animations and game time), but the OnApplicationPause method is never called, someone have an idea why?? or how can I force to call this method???
I'll really apreciate your help.
Thanks for your time, cheers from Mexico.
Hi Everybody.
I already fix that, but I don't force to call the OnApplicatioPause method.
We was extends from Activity of Android.
--public class game extends Activity {
Now, correctly we are Extends form UnityPlayer.
public class game extends UnityPlayerActivity {
For that reason the Activity detects the OnPause and OnResume from phone, but it doesn't have control in Unity.
Now Extended by UnityPlayerActivity we can control all the player of Unity, music and all game...
Sorry if that question and answer was dumb...
Thanks and Cheers.
Answer by HazeTI · May 23, 2012 at 10:17 AM
What version of Unity are you using?
According to 3.4.2 Release Notes the audio problem has been fixed. "Allow audio playback only when application is focused (prevents audio on the unlock screen)."
Also you should put logging in OnApplicationPause and OnApplicationFocus to see when each of them is called and act accordingly for your app.
Thanks for your answer and your time, my Unity is 3.5.
As I commented, the application is like never enter to OnApplicationPause and OnApplicationFocus, I put a message in those methods and they never are print.
I guess, that methods never are called by themselves, then the application is never paused. Also I think that are the same reason for never stop the "SoundPlayer", and still show the "$$anonymous$$edia volume", when I press the volume keys and the application is in background.
Thanks again, and I hope you can help us more.
Cheers
Your answer
Follow this Question
Related Questions
Android - Mute button not working when returning from home screen 1 Answer
How to run Android service behind UnityPlayerActivity? 0 Answers
PlayerPrefs not Saving Properly on Android (Works in Editor) - OnApplicationPause/Quit 1 Answer
Buttons remain in pressed state upon performing home interrupt 0 Answers