Many posts are there for this issue.But the solutions are available for when the activity gets paused. I tried all it doesn't work. My problem is little bit different
I have a videoview and when the user clicks the videoview ,video will be paused and if he clicks again it should be resumed.
My code snippet in ontouchlistener is,
videopath = getIntent().getStringExtra("path");
imageView = ((VideoView) findViewById(R.id.imageView));
imageView.setVideoPath(videopath);
imageView.start();
imageView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_UP)
if (layout.getVisibility()==View.VISIBLE) {
imageView.seekTo(stopPosition);
imageView.resume();
layout.animate().translationY(-layout.getHeight()).setDuration(500);
layout.setVisibility(View.GONE);
hideSystemUI();
} else {
imageView.pause();
stopPosition=imageView.getCurrentPosition();
showSystemUI();
layout.setVisibility(View.VISIBLE);
layout.animate().translationYBy(layout.getHeight());
}
return true;
}
});
I got this solution from this link . It doesn't work and simply using resume(); is also not working.