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 jhelton · Jun 15, 2013 at 01:05 AM · androidbackgroundpausesleepresume

My Unity Android app is preventing the lock screen from displaying properly

I am working on a Unity project that is on iOS and Android. On Android, while the app is open, when the device sleeps and then the user hits the power button, the app is in the foreground. In this case, the user's lock screen should come up. If the user hits the home button at this point, then the lock screen appears.

I have looked for all the various settings that I can think of that could be causing this behavior - running in the background, sleep timeout, etc. The project does not have any of these settings enabled. Other Unity apps that I have seen do not have this behavior.

Any ideas on what we could be setting or doing that would cause this behavior?

Comment
Add comment · Show 2
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 seandanger · Aug 22, 2013 at 09:30 PM 0
Share

Same problem here. Can't find a solution yet, will update if I do.

avatar image mrdoktor1974 · Jan 09, 2014 at 10:03 AM 0
Share

Has anyone solved this? Can't find anything about wake-lock in my manifest either.

2 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by Andy-Block · Apr 11, 2015 at 02:28 PM

If you are in "Development Mode" this is the default behavior of the application.

Source: http://forum.unity3d.com/threads/game-is-preventing-the-lock-screen-from-appearing.205632/

Comment
Add comment · 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
1

Answer by meat5000 · Aug 22, 2013 at 10:34 PM

I'm going to hazard a guess. I could be way off.

http://developer.android.com/reference/android/os/PowerManager.WakeLock.html

Wake-lock is set, asking the phone to stay on. Android is overriding this or the Screen Sleep is timing out and so the device sleeps anyway. When you resume, the lock-screen is still held in the queue as it was prevented by wake lock. When you press the Home button the wake lock is released and so the next queued intent is used which is the lock screen.

On Build, export your project as an Eclipse project. Once imported in to Eclipse check the XML manifest to see if Wakelock is allowed (if it is try disallowing it). Use eclipse to Run the app on your phone and check the LogCat info to see what is happening.

This may be one to post on StackOverflow.

Edit : Export to Eclipse is now "Google Android Project" in Build Settings, as of Unity 4.2

Comment
Add comment · Show 6 · 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 Bunny83 · Aug 22, 2013 at 11:11 PM 0
Share

Something like that... ;) It started with Android version 4.3. At least there i've noticed this behaviour first. It's not related to Unity since i can say almost for certain that before Android 4.3 the lock screen showed up after sleeping. We still use Unity 4.0.xx so it's not Unity related since we didn't update Unity, only the Android version.

Android 4.3 have brought some more problems. It seems $$anonymous$$ono has a bug which was not a problem until Android 4.3 came out.

avatar image meat5000 ♦ · Aug 22, 2013 at 11:17 PM 0
Share

Agreed. However I had games on A4.1.2 that skipped the lock screen on wake, so it is optional. I've got 4.2.2 now and that introduced some zany behaviours! After hitting home button sometimes my game would run as a wallpaper :D:D:D lol@$$anonymous$$ono bug link

Best not to live on the cutting edge. It effin hurts!

avatar image jhelton · Aug 22, 2013 at 11:18 PM 0
Share

Actually, I can say for certain that it is not related to Android 4.3. I have devices ranging from 2.3 up to 4.3. It happens on all of them. I am on Unity 4.0.1 because newer versions of Unity crash on the Galaxy S2.

Bunny83, if you are certain that your project was once in a state where this wasn't happening, then I'm guessing you might be able to step back in your project to a state where this wasn't happening (assu$$anonymous$$g good version control). That would be very useful. In my case, this started happening from the first time I got the project running on Android, which was in January or February.

avatar image meat5000 ♦ · Aug 22, 2013 at 11:21 PM 0
Share

jhelton, are you exporting in to an environment that was setup and hasn't been changed for a while? For example, I've set up eclipse once and I've not touched it since except to import from Unity. Or do you build the Apk directly from Unity?

avatar image jhelton · Aug 22, 2013 at 11:24 PM 0
Share

meat5000, I build the apk from Unity directly, kind of. We use a build script in unity to trigger the builds. This allows us to use Jenkins to do auto-builds. I haven't tried your Eclipse export suggestion, but my Android$$anonymous$$anifest.xml doesn't contain a wakelock permission.

Show more comments

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

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Android lag when home key is pressed 1 Answer

Android application not responding out of sleep mode. 1 Answer

SubView with Transparent Background 0 Answers

2D main menu as a different scene - pausing and resuming 0 Answers

Android app freezing on splash screen 0 Answers


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