Problems with Acitivity LifeCycle with VideoView playback.
- by Alex Volovoy
Hi all i've ran into another problems with VideoView.
Then video is playing, and i put device asleep, using hard button, onPause is called. But it followed by
03-17 11:26:33.779: WARN/ActivityManager(884): Activity pause timeout for HistoryRecord{4359f620 com.package/com.package.VideoViewActivity}
And then i have onStart/onResume again and Video starts playing. I've try to move code around onStart/onStop - doesn't seems to make difference.
sample code :
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);
}
}