Skip to content

Instantly share code, notes, and snippets.

@cypressious
Forked from pepyakin/ExampleApplication.java
Last active November 24, 2016 08:50
Show Gist options
  • Save cypressious/91c4fb1455470d803a602838dfcd5774 to your computer and use it in GitHub Desktop.
Save cypressious/91c4fb1455470d803a602838dfcd5774 to your computer and use it in GitHub Desktop.
Gist which should prevent leaks of Activity in ClipboardUIManager.
public class ExampleApplication extends Application {
@Override public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= 21) {
try {
Class<?> cls = Class.forName("android.sec.clipboard.ClipboardUIManager");
Method m = cls.getDeclaredMethod("getInstance", Context.class);
m.setAccessible(true);
Object o = m.invoke(null, this);
} catch (Exception ignored) { }
}
}
}
@imesong
Copy link

imesong commented Nov 24, 2016

I hava a question about why limit the SDK version to 21 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment