大家好,我遇到了另一个问题VideoView
。然后视频正在播放,我使用硬按钮让设备进入睡眠onPause()
状态。但紧随其后的是:
03-17 11:26:33.779: WARN/ActivityManager(884): Activity pause timeout for HistoryRecord{4359f620 com.package/com.package.VideoViewActivity}
然后我再次onStart()
/onResume()
并且视频开始播放。我试图移动代码onStart()
/ onStop()
- 似乎没有什么区别。
示例代码:
public class VideoViewActivity extends Activity {
private String path = "";
private VideoView mVideoView;
private static final String MEDIA_URL = "media_url";
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView)findViewById(R.id.surface_view);
path = getIntent().getStringExtra(MEDIA_URL);
}
@Override
public void onResume() {
super.onResume();
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.start();
}
@Override
public void onPause() {
super.onPause();
mVideoView.stopPlayback();
mVideoView.setMediaController(null);
}
}
为什么会这样?我该如何阻止呢?
让设备进入睡眠状态并开始播放视频并不是最棒的体验