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
0
Question by Kantharr · Aug 14, 2012 at 08:48 PM · androidsleeppower

Android Sleep Mode Problem

Hey guys,

I am having a problem detecting when my android device enters or exits sleep mode when you press the power button. Does it send a message kind of like OnApplicationPause() or OnApplicationFocus() when it enters or exits sleep mode? The reason why I want to detect this is because when I have a touch keyboard opened in my game and I press the power button to put it to sleep, the game screen will become black but the keyboard will be shown when you wake the phone back up. Here is the process of it occuring:

  1. Activate touch keyboard with TouchScreenKeyboard.Open()

  2. Put android phone into sleep mode with the power button

  3. Press the power button again to wake the phone back up.

What I want the game to do is to turn off the keyboard whenever the user enters or exits sleep mode so that the screen will no longer be black and actually show all of my UI elements. Any kind of help will be greatly appreciated.

[Edit] Wanted to add some new information to help clarify my problem. I am coding in C# only and I am also using NGUI with Multi-Platform ToolKit Suite on the game. I have tried searching everywhere and the only thing that I have found was that the function OnResume() is called but that is a java only function isn't it? Is there a C# version of it? I have tried OnApplicationPause() and OnApplicationFocus() but no luck. I have found out that the back button sends an Keycode.Escape for Input so what would keycode be when you press the power button?

[Edit2] Okay I sort of fixed my problem, was doing too much work on it lol. Apparently OnApplicationPause does work but instead of OnApplicationPause(bool pause) I had OnApplicationPause(bool paused). It sucks that one letter can ruin your whole project. So now in order to fix my whole problem I just need to know how do I send a message of some kind to force close the android touchscreen keyboard. Setting the active value to false doesn't help me and the done value is read-only so I can't just set it to done.

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

0 Replies

· Add your reply
  • Sort: 

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

7 People are following this question.

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

Related Questions

A node in a childnode? 1 Answer

How do I reset Screen.sleepTimeout's user input timer? 1 Answer

Keep Android App running when screen is locked 0 Answers

File size is bigger than Build Size from log 1 Answer

Making Unity player background as transparent in android app 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