Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
6
Question by robeth · Jul 12, 2012 at 10:20 AM · androidpauseapplicationhome button

Send Application to background/Paused in Android

Currently i have my application "fully ended" by pressing Back Button in android device. Thus my application not exist in task manager anymore.

 function Update(){ 
     if(Input.GetKeyDown("escape"))
         Application.Quit();
 }

How do i make application is paused and still exist in the task manager when back button is pressed? It is the same effect when the home button is pressed.

Comment
Add comment · Show 6
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 SolidSnake · Aug 17, 2012 at 10:08 AM 0
Share

Any luck with this one? I am wondering the same thing

avatar image robeth · Aug 17, 2012 at 04:47 PM 0
Share

Nope :(

So far, i use confirmation box whether the user really want to exit in case back button pressed accidentally

avatar image Fattie · Jan 24, 2016 at 04:58 PM 0
Share

Right, it's quite incredible nobody has an answer to this??

avatar image ZiadJ · Sep 06, 2018 at 06:21 AM 0
Share

I guess it's safe to say that Unity provides no way to move an app to the background then.

avatar image ecv80 · Nov 03, 2018 at 03:42 PM 0
Share

https://answers.unity.com/questions/846128/android-how-to-movetasktoback-and-$$anonymous$$imze-the-app.html

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by IMD · Nov 23, 2018 at 12:59 PM

Hi, so for making the Android back button send the app to the background you can use the following code in any Monobehaviour in the current scene:

     void Update()
     {
         #if UNITY_ANDROID
         //added for Android back button reaction
         if (Input.GetKeyDown(KeyCode.Escape))
         {
             AndroidJavaObject activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");
             activity.Call<bool>("moveTaskToBack", true);
         }
         #endif
 
     }
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

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

11 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

Related Questions

Differentiate App closed and minimized 0 Answers

Android lag when home key is pressed 1 Answer

make a bouncing ball move slightly to the left or right, 1 Answer

Class Application.CaptureScreen no running in android 0 Answers

Android, Game doesn't minimize when pressing power. -1 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