当应用程序从后台进入前台时,onBackPressed()不起作用

我的活动中有一个videoView。当app从后台进入前景时,以及由于videoView.seekTo(1)我锁定手机并解锁手机时,onBackPress()均不起作用。我们该如何解决

下面是我的代码。请帮忙

public class VideoPreviewActivity extends implements View.OnClickListener  {

    TextView tv_response;
    ImageView iv_video_preview;
    VideoView videoView;
    @SuppressLint({"ClickableViewAccessibility", "InlinedApi"})
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_preview);
        processIntent(getIntent());
    }


    public void processIntent(Intent intent) {
        int is_doc_context = intent.getIntExtra(IS_DOC_CONTEXT, 2);
        if (is_doc_context == 1) {

            final MediaController mc = new MediaController(this);
            mc.setVisibility(View.GONE);
            mc.setAnchorView(videoView);
            mc.setMediaPlayer(videoView);
            final Uri video = Uri.parse(videoFileString);
            videoView.setMediaController(mc);
            videoView.setVideoURI(video);
            videoView.seekTo( 1 );

            videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                @Override
                public void onCompletion(MediaPlayer mp) {
                }
            });
        } 
    }

    @Override
    protected void onResume() {

        videoView.seekTo( 1 );
        super.onResume();
    }

    @Override
    protected void onPause() {

        if (videoView.isPlaying()){
            videoView.stopPlayback();
        }
        super.onPause();
    }

    @Override
    public void onBackPressed() {
        LibUtils.onBackButtonClick(VideoPreviewActivity.this);
    }
}

如果您需要任何信息,请告诉我。

评论