Last active
December 12, 2015 08:59
-
-
Save menny/4747886 to your computer and use it in GitHub Desktop.
Android Memory Leaks OR Different Ways to Leak
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AnySoftKeyboard extends InputMethodService { | |
private static final class KeyboardUIStateHanlder extends Handler { | |
//This will NOT be counted as a reference! | |
private final WeakReference<AnySoftKeyboard> mKeyboard; | |
public KeyboardUIStateHanlder(AnySoftKeyboard keyboard) { | |
mKeyboard = new WeakReference<AnySoftKeyboard>(keyboard); | |
} | |
@Override | |
public void handleMessage(Message msg) { | |
AnySoftKeyboard ask = mKeyboard.get(); | |
if (ask == null)//delayed posts and such may result in the reference gone | |
return; | |
switch (msg.what) { | |
case MSG_UPDATE_SUGGESTIONS: | |
ask.performUpdateSuggestions(); | |
break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment