2011-09-12 76 views
4

如何避免重新加載視頻方向變化,即迫使視頻從其中恢復。安卓視頻重新定向

下面我嘗試,但它無法

vd = (VideoView) findViewById(R.id.vplayer); 
....... 
public void onSaveInstanceState(Bundle savedInstanceState) { 
    super.onSaveInstanceState(savedInstanceState); 
    savedInstanceState.putInt("Position",vd.getCurrentPosition()); 
} 

public void onRestoreInstanceState(Bundle savedInstanceState) { 
    super.onRestoreInstanceState(savedInstanceState); 
    int position= savedInstanceState.getInt("Position"); 
    vd.seekTo(position); 
} 

回答

7

你可以做的是停止你的活動來獲得重新創建時的方向變化。您可以通過在AndroidManifest.xml文件中添加activity tag

android:configChanges="keyboardHidden|orientation"