如何避免重定位方向改变的视频重新加载,即强制视频从同一视频恢复.
我试过下面但它失败了
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);
}
解决方法:
您可以做的是在方向更改时停止重新创建活动.您可以通过在activity标记中添加AndroidManifest.xml文件来实现
android:configChanges="keyboardHidden|orientation"