Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by el_ewok · May 22, 2012 at 07:04 AM · androidonapplicationpauseinterrupt

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.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image el_ewok · May 25, 2012 at 12:59 AM 0
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image el_ewok · May 24, 2012 at 06:32 PM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

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

handling android deep links on unity apps 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges