gpt4 book ai didi

android - VideoView 播放视频时后退按钮不起作用

转载 作者:行者123 更新时间:2023-12-02 10:02:25 26 4
gpt4 key购买 nike

我的一个 Activity 中有一个 VideoView,如果我尝试按后退 Button,它不会将我带到之前的 Activity 并且它也不会在日志猫中给出任何错误消息。

我尝试覆盖 onBackPressed() 方法,并且尝试使用 Intent 调用前一个 Activity,但即便如此,后面的Button 没有执行任何操作。

此问题仅在视频播放时甚至播放完毕后出现。后退按钮唯一起作用的时间是在视频开始播放之前。我的 VideoView 还设置了一个 MediaController

有什么想法吗?

谢谢!

最佳答案

From CommansWare

Based on the source code, this should work:

  1. Extend MediaController (for the purposes of this answer, call itRonnieMediaController)
  2. Override dispatchKeyEvent() in RonnieMediaController
  3. Before chaining to the superclass, check for KeyEvent.KEYCODE_BACK,and if that is encountered, tell your activity to finish()
  4. Use RonnieMediaController instead of MediaController with yourVideoView

Personally, I'd just leave it alone, as with this change your usercannot make a RonnieMediaController disappear on demand.

Here is the link to the original post.

关于android - VideoView 播放视频时后退按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11779692/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com