VideoView does not match activity orientation setting

I am trying to create a simple activity that plays a short video. It works great, except for the orientation of the video: I blocked the orientation of activity in the portrait, and this works when the VideoView starts playing the video. However, after a few seconds, it seems that VideoView / MediaPlayer does not match the orientation of the activity in which it is located.

Please note that the activity is not recreated, the video changed its own configuration during playback.

EDIT:

This orientation changed the reason when I try to finish this activity with another AsyncTask background activity, note that I tried to do this with startActivityForResults (...) .. finishActiviy (...). We also send Intent (Single_top), which should ask you to finish it yourself. Note that FLAG_ACTIVITY_REORDER_TO_FRONT does not change orintation. Here is the code used to block orintation (not one of them worked)

this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); //OnCreate
android:screenOrientation="portrait" //manifest
android:screenOrientation="portrait" //layout

Here is the code I used to play the video activity:

protected onCreate(Bundle savedInstance){
    .
    .
    .
    videoHolder = (VideoView) findViewById(R.id.videoView);
    videoHolder.setVideoURI(Uri.parse("android.resource://" +          getPackageName() + "/" + R.raw.video));
    videoHolder.start();
}

location:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center"
    android:keepScreenOn="true" >

    <VideoView
        android:id="@+id/videoView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:screenOrientation="portrait" />

</RelativeLayout>

enter image description here

+5
source share

All Articles