xhlwill
xhlwill

Reputation: 399

When the orientation change from portrait to landscape, the video starts from the beginning in Android?

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?

Upvotes: 1

Views: 1170

Answers (3)

Vinayak Bevinakatti
Vinayak Bevinakatti

Reputation: 40503

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

Upvotes: 1

arpit
arpit

Reputation: 555

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.

Upvotes: 0

Jordi Coscolla
Jordi Coscolla

Reputation: 1066

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

Upvotes: 0

Related Questions