After i install my game on my android device (haven’t tested on other devices) it works perfect the first time, then i exit out of it, open it again it doesn’t work correctly. All of the functionality is off by a little, some of the touches don’t recognize, it runs slower, ect. Also, if i force quite the app, then restart it, the app works perfectly every time after that. It might be device specific but don’t really have a way of checking. I would be willing to upload the .apk for somebody to test if that’s cool? Ive tried messing around with the build settings, mostly just guessing, cause i don’t know what most of them do anyways, but nothing has worked and i can’t tell a difference when i do change the build settings. At this point I’d be willing to try anything so any suggestions would help.
Build settings just for kicks:
Testing on Droid 3
Static Batching:Yes
Dynamic Batching:Yes
Device Filter: Android 2.0.1 ‘Eclair’(API level 6
Graphics Level: ARMv7 only
API Compat Level .NET 2.0 Subset
Stripping Level: Disabled
The thing is, that Android doesn’t aways destroy an app after you exit the app - or you app isn’t really exiting.
Try downloading one of those third party task managers from the Market that list ALL the processes that are running. Start up the task manager, start up your game, exit your game - and then check the task manager.
That fact that you can kill the app, start it again, and it works perfectly, means to me that it isn’t exiting cleanly for some reason.
thanks!, Downloaded the task manager and yes it is still running after i exit out by pressing the home button during play. If i manually stop the app and start it again then it works fine all the time. I also tried it on another phone the problem occurred exactly the same as my phone. Gonna try to quit the app if it’s not focused, with this:
the focus didn’t work, but i figured out the problem, it’s having problems because it’s installing the game on my sd card and not the actual phone. Is there a way to determine where the application is installed on the phone?
It will by default always install on SD card, if one is available. Only exceptions are devices with huge internal memory and/or no sd card.
Focus of course don’t work, because you’re using an Editor Class which only works in the Unity Editor (who would have guessed that…). You may want to look at Unity - Scripting API: MonoBehaviour and it’s OnApplicationXXX Methods.
However, a word of warning: It’s a very bad idea to kill the game on focus loss. The user may receive a call during game and the game will automatically be put in the background (or it should at least). After the call is done, the user want to resume where he stopped. Killing the game and forcing him to lose progress may make it frustrating for some players.
It’s default Android behavior to regularly put Apps in the background and resume them later. You should have a button (in the pause menu) where the user can clicks on to quit the game or bind it with the back key. Many user will just use the home key to get the phones desktop in t he foreground and do something else and then come back and continue the game, so you can’t simply “kill” the game when they do, that’s not very customer friendly.
I only had problems with the TouchPhase, which I don’t use anymore. It seems that some TouchPhase.Began and/or TouchPhase.Ended were like out of synch.
I check the selection of an object in the game with Raycasts and the position of the touch. When I did that by raycasting when TouchPhased.Ended == true (I tested also with TouchPhase.Began == true), some clear hits went undetected after I interruped the game with the Menu button and reopened it. After forcing the App to quit and a restart, the game’s behavior went back to normal. It’s not something that I verified truly but since I do not query the TouchPhase anymore, the problem is gone. (cf http://forum.unity3d.com/threads/117477-Android-Touch-problems)