Skip to content

Instantly share code, notes, and snippets.

@pszklarska
Last active June 17, 2017 15:31
Show Gist options
  • Save pszklarska/6fbd3b7485b8077925a80ebf47f7fa40 to your computer and use it in GitHub Desktop.
Save pszklarska/6fbd3b7485b8077925a80ebf47f7fa40 to your computer and use it in GitHub Desktop.
package pl.pszklarska.leakexample;
public class AnonymousClassLeakActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(final Void... voids) {
// Here is operation, which takes a long time...
Context context = AnonymousClassLeakActivity.this;
loadMillionCatsPhotos(context);
return null;
}
}.execute();
}
private void loadMillionCatsPhotos(Context context) {
// Cat 1 loading...
// Cat 2 loading...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment