App restarts when screen is rotated

by Digeridoo » Wed, 27 Apr 2011 04:53:13 GMT


Sponsored Links
 Hi All,

My game app resets to start position when I rotate the phone from
portrait to landscape or the other way round. Do I need to disable the
gravity sensor and do I do this in the OnCreate method?

-- 



Re: App restarts when screen is rotated

by Farah Hanif » Wed, 27 Apr 2011 04:58:15 GMT


 You need to get configChanges of your activity to "orientation".  This means
that app will handle all the orientation changes by itself.

See
 http://developer.android.com/guide/topics/manifest/activity-element.html #config

  android:configChanges
< http://developer.android.com/guide/topics/manifest/activity-element.html #config>=["mcc",
"mnc", "locale",
                                 "touchscreen", "keyboard", "keyboardHidden",
                                 "navigation", "orientation", "screenLayout",
                                 "fontScale", "uiMode"]



On Tue, Apr 26, 2011 at 4:53 PM, Digeridoo







-- 
*Farah Hanif*
613-851-9128

-- 


Sponsored Links


Re: App restarts when screen is rotated

by lbendlin » Wed, 27 Apr 2011 04:58:51 GMT


 Activities are destroyed and recreated by default when the orientation 
changes. If you don't like that you can use various methods to either 
prevent that from happening (by handling orientation changes yourself) or to 
restore the state of the activity. 

-- 



Re: App restarts when screen is rotated

by TreKing » Wed, 27 Apr 2011 05:31:36 GMT


 On Tue, Apr 26, 2011 at 3:53 PM, Digeridoo




 http://developer.android.com/reference/android/app/Activity.html #ConfigurationChanges


-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

-- 



Re: App restarts when screen is rotated

by Indicator Veritatis » Wed, 27 Apr 2011 06:25:36 GMT


 Of the two approaches lbendlin mentions, the latter is more commonly
recommended. I used to know why.




-- 



Re: Re: App restarts when screen is rotated

by TreKing » Wed, 27 Apr 2011 06:30:36 GMT


 



Because your app can be killed and recreated by other means - like when the
user presses Home and does other things for a while. If you properly handle
saving and restoring instance state, you'll survive this case as well. If
you only handle the config changes, then you will fail this case and a user
coming back to your game will have to start over.

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

-- 



Other Threads

1. MOTODEV App Summit Buenos Aires

FYI...  hispanos and comunity

http://developer.motorola.com/eventstraining/summit/buenosaires/?hl=es-419&utm_campaign=20110509-summit11latam&utm_medium=ES&utm_source=email&utm_content=baires&utm_term=lastchance

-- 

2. DeviceMonitor]Failed to start monitoring <Device-number>

I have the same problem, any solution anyone?

/Emil




--

3. Wanted: Convmv for Android, a useful tool

4. [OpenGL ES] Using transparent png textures won't work

5. Has Android support of parsing WBXML (SyncML, OMA standarts)??

6. How to change Notification Duration on HoneyComb?

7. thread.join() works only with debugger