当前 Activity 已经销毁或者当前页面不在前台,但是视频还在继续播放着,必须杀掉 App 才可以停止,这样用户体验就非常不好。
- 解决办法
@Override
protected void onResume() {
super.onResume();
if (wv_content != null) {
wv_content.onResume();
}
}
@Override
protected void onPause() {
super.onPause();
if (wv_content != null) {
wv_content.onPause();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (wv_content != null) {
wv_content.destroy();
}
}
在相应的Activity的生命周期中调用对应 WebView 的生命周期的方法,就可以解决了。
/**
* --------------
* 欢迎转载 | 转载请注明
* --------------
* 如果对你有帮助,请点击|顶|
* --------------
* 请保持谦逊 | 你会走的更远
* --------------
* @author zsl
* @github https://github.com/yy1300326388
* @blog http://blog.csdn.net/yy1300326388
*/