Skip to content

Instantly share code, notes, and snippets.

@zi6xuan
Created September 11, 2019 06:46
Show Gist options
  • Save zi6xuan/854cef6dc3335f470a9ec45cb494e643 to your computer and use it in GitHub Desktop.
Save zi6xuan/854cef6dc3335f470a9ec45cb494e643 to your computer and use it in GitHub Desktop.
Fix the VideoView memory leak
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(new ContextWrapper(newBase){
@Override
public Object getSystemService(String name) {
if(Context.AUDIO_SERVICE.equals(name)){
return getApplicationContext().getSystemService(name);
}
return super.getSystemService(name);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment