本文主要是介绍Android - VideoView需要按两次BACK才能退出解决方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
从Android back button and MediaController - Stack Overflow得到启发,开始是个秀才认字认半边,没有把文章和回复看全,然后高版本的Android还是没有解决。后来看到以下回复:
The previous solutions no longer work with Android Pie +, you must instead :
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {mediaController.addOnUnhandledKeyEventListener((v, event) -> {//Handle BACK buttonif (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP){mediaController.hide(); //Hide mediaController,according to your needs, you can also called here onBackPressed() or finish() }return true;});}
豁然开朗
这篇关于Android - VideoView需要按两次BACK才能退出解决方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!