1

I am writing an Android project, at beginning I am playing a video in portrait mode, a few seconds later when i change it from portrait to landscape, the video starts from the beginning(0's)? why?

I have set android:configChanges="orientation" in AndroidManifest.xml and added onConfigurationChanged().

How to let it play from the last position of portrait mode while the mode changes?

xhlwill
  • 399
  • 1
  • 5
  • 20

3 Answers3

1

onSaveInstanceState() and onRestoreInstanceState are the methods meant to remember and restore the current state when a configuration change occurs like e.g. a screen orientation change.

Refer the link - https://stackoverflow.com/a/151940/28557

Community
  • 1
  • 1
Vinayak Bevinakatti
  • 40,205
  • 25
  • 108
  • 139
  • Thank you for the link. Could you kindly give the command which makes the activity to remember the video paused position. what we should add in extras – Prabs Aug 03 '15 at 12:11
0

The general way of android to handle the orientation is recreating the entire activity.

If you whant to handle yourself you have to modify the AndroidManifest.xml and set this attribute to the activity node:

android:configChanges="orientation"

More information in this post

Jordi Coscolla
  • 1,066
  • 6
  • 8
  • I have set android:configChanges="orientation" in AndroidManifest.xml and added onConfigurationChanged()! sorry, i forgot to say – xhlwill Feb 08 '12 at 09:30
  • was the data lost when the layout changes, though activity has not been destroyed? – xhlwill Feb 08 '12 at 09:35
0

actually when you change change the orientation of screen the activity is first destroyed and then recreated it. you should check activity life cycle methods by grammatically.

arpit
  • 555
  • 1
  • 7
  • 25
  • I have set android:configChanges="orientation" in AndroidManifest.xml, so the activity will not be recreated. – xhlwill Feb 09 '12 at 02:05