0

I am using both landscape and portrait for an application.

My problem is,whenever i rotate the screen,the TTS I am using in my application automatically

starts from first.

How do I solve this problem?
DevAndro
  • 205
  • 1
  • 6
  • 18

1 Answers1

1

By default, Android restarts/recreates the activities whenever the orientation change.

You will need to save your data/state by calling onSaveInstanceState() before Android destroys the activities.

Have a look at Handling Runtime Changes

As the last resort, you could prevent this by adding android:configChanges="orientation" to your activity in AndroidManifest file.

Rahul
  • 44,383
  • 11
  • 84
  • 103
  • android:configChanges="orientation" should be last resort. use onSaveInstanceState() and onRestoreInstanceState() first. – Rohit Sharma Mar 19 '13 at 05:49
  • My app has all 4 layouts,i.e,small,normal,large and Xlarge. For Large and Xlarge I am using only Landscape and for small I am using only portrait by controlling it in java codes. For Normal I am using both Landscape and Portrait. So i cant change my AndroidManifest file. – DevAndro Mar 19 '13 at 06:13
  • Mentioned Last resort is not your Last resort then... Go for the first option – Rohit Sharma Mar 19 '13 at 08:40