Skip to content

Instantly share code, notes, and snippets.

@ali-star
Last active June 14, 2024 12:27
Show Gist options
  • Save ali-star/5fac9183a74dcb454a881939041968e5 to your computer and use it in GitHub Desktop.
Save ali-star/5fac9183a74dcb454a881939041968e5 to your computer and use it in GitHub Desktop.
LeakCanary EventListener
class DebugApplication : Application() {
override fun onCreate() {
super.onCreate()
val analysisUploadListener = EventListener { event ->
if (event is EventListener.Event.HeapAnalysisDone.HeapAnalysisSucceeded) {
val heapAnalysis = event.heapAnalysis
TODO("Intercept leaks")
}
}
LeakCanary.config = LeakCanary.config.run {
copy(eventListeners = eventListeners + analysisUploadListener)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment