码迷,mamicode.com
首页 > 其他好文 > 详细

Activity横竖屏切换时 一些数据的保存

时间:2016-03-15 19:02:43      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:

private VideoView videoView;  
02.private static final String VIDEO_PATH = Environment  
03.        .getExternalStorageDirectory()  
04.        + File.separator  
05.        + "mymovie"  
06.        + File.separator + "shenghuaweiji.mp4";  
07.  
08./** Called when the activity is first created. */  
09.@Override  
10.public void onCreate(Bundle savedInstanceState) {  
11.    super.onCreate(savedInstanceState);  
12.    setContentView(R.layout.main);  
13.    Log.v("tag", "onCreate");  
14.     
15.    if (videoView == null) {  
16.        videoView = (VideoView) this.findViewById(R.id.myvideo);  
17.        MediaController controller = new MediaController(this);  
18.        videoView.setMediaController(controller);  
19.        videoView.setVideoPath(VIDEO_PATH);  
20.        videoView.requestFocus();  
21.    }  
22.  
23.    if (savedInstanceState != null  
24.            && savedInstanceState.getInt("currentposition") != 0) {  
25.  
26.        videoView.seekTo(savedInstanceState.getInt("currentposition"));  
27.    }  
28.    videoView.start();  
29.  
30.}  
@Override  
  • protected void onSaveInstanceState(Bundle outState) {  
  •     // TODO Auto-generated method stub  
  •     outState.putInt("currentposition", videoView.getCurrentPosition());  
  •     Log.v("tag", "onSaveInstanceState");  
  •     super.onSaveInstanceState(outState);  
  • }   

 

Activity横竖屏切换时 一些数据的保存

标签:

原文地址:http://www.cnblogs.com/bimingcong/p/5280554.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!