遇到了许多人已经遇到的VideoView内存泄漏。我已经按照以下方式处理了我的代码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
String path = "android.resource://" + getPackageName() + File.separator + R.raw.splash_video;
videoView.setOnCompletionListener(this);
videoView.setOnErrorListener(this);
videoView.setVideoURI(Uri.parse(path));
videoView.start();
}
@Override
protected void onDestroy() {
videoView.setOnCompletionListener(null);
videoView.setOnErrorListener(null);
super.onDestroy();
}
内存泄漏报告如下所示:
我尝试了以下链接中提供的解决方案,但没有任何效果。
https://gist.github.com/jankovd/891d96f476f7a9ce24e2
https://medium.com/@chauyan/confirmed-videoview-leak-on-android-ac502856a6cf
任何帮助将不胜感激!