How do you terminate the current Unity app on the iPhone or Android? How do you make an app close itself?
Why: When you have multitasking, you want to have an exit option so the user doesn’t just have that app hanging in memory.
How do you terminate the current Unity app on the iPhone or Android? How do you make an app close itself?
Why: When you have multitasking, you want to have an exit option so the user doesn’t just have that app hanging in memory.
I have to question that logic. What does it cost you to have an application in memory?
Does it stop you opening new applications because you’ve run out of memory? No.
Would you be able to use the reclaimed memory for something else? No.
Would you save valuable power? Probably not, I’d imagine you can’t cut power to parts of ram.
The task memory manager does a fantastic job of keeping you running and closing unused applications as you need memory.
Having said that we have received bad reviews because we don’t have an explicit exit button and people fear we’re chewing up their battery in the background.
We will cave in and add a explicit exit button to appease these people, but it would be wrong if I didn’t try and expel the myth.
Application.Exit()
Speaking of which does the final splashscreen not work on Android either: Unity - Scripting API: Application.CancelQuit
You already asked this on UnityAnswers, and I don’t know about Android, but on iOS the answer isn’t going to change: You don’t put quit buttons in iOS apps. To leave an app, you press the home button. That’s it. You don’t manage the memory yourself; the OS does it for you. If it needs RAM to run a new app, it closes already-launched apps as necessary.
–Eric
@Eric5h5 - Note that this is posted in the Android forum… >.>
@DTreble: BCE0019: ‘Exit’ is not a member of ‘UnityEngine.Application’.
Application.Quit() seems to work - or return to the home screen at least, but the app still runs in background (though when you multitask back, it’s from the Start() state).
You’re quite right, it’s Quit(). However I think you missed my point entirely.
You should probably read an article like this Android Task Killers Explained: What They Do and Why You Shouldn’t Use Them
Note that the question specifically mentions “iPhone”. ![]()
–Eric
How do you determine that it’s still running? If the application is still running, that is a bug.
If you do add a call to Application.Quit() I recommend you to conform to the standard of using the BACK button (KeyCode.Escape) to trigger it.
As a rule (with a lot of exceptions ofcourse) an application quits when the BACK button is pressed, but ‘sleeps’ after pressing the HOME button (or if you receive a phone call etc). It’s also recommended to ‘mimic’ the Android application stack behavior, meaning BACK will always take you back to your last choice (i.e. pressing BACK ingame goes back to the frontend menu from where, if you press BACK again, will quit the game).
Obviously for some applications this might not make sense. But this is how Android applications work ‘by default’.
The BEST explanation for how to quit iDevices Apps. Take a look to this link:
http://www.maclife.com/article/howtos/how_quit_apps_your_ipad