Skip to content

Commit

Permalink
Add LeakCanary#createLeakDisplayActivityIntent (#1341)
Browse files Browse the repository at this point in the history
Resolves #1337

Kept it as a function rather than a val since the best we could do due to the context requirement would be an awkward `lateinit var`.
  • Loading branch information
ZacSweers authored and pyricau committed May 8, 2019
1 parent 01210bb commit e4a16de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 10 additions & 0 deletions leakcanary-android-core/src/main/java/leakcanary/LeakCanary.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package leakcanary

import android.app.Application
import android.content.Context
import android.content.Intent
import leakcanary.AndroidExcludedRefs.Companion.exclusionsFactory
import leakcanary.internal.InternalLeakCanary
import leakcanary.internal.activity.LeakActivity

typealias AnalysisResultListener = (Application, HeapAnalysis) -> Unit

Expand Down Expand Up @@ -50,4 +53,11 @@ object LeakCanary {

@Volatile
var config: Config = Config()

/**
* @return a new [Intent] that can be used to programmatically launch the leak display activity.
*/
fun createLeakDisplayActivityIntent(context: Context): Intent {
return LeakActivity.createIntent(context)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import leakcanary.CanaryLog
import leakcanary.GcTrigger
import leakcanary.LeakCanary
import leakcanary.LeakSentry
import leakcanary.internal.activity.LeakActivity

internal object InternalLeakCanary : LeakSentryListener {

Expand Down Expand Up @@ -138,7 +137,7 @@ internal object InternalLeakCanary : LeakSentryListener {
return
}

val intent = LeakActivity.createIntent(application)
val intent = LeakCanary.createLeakDisplayActivityIntent(application)
intent.action = "Dummy Action because Android is stupid"
val shortcut = Builder(application, DYNAMIC_SHORTCUT_ID)
.setLongLabel(longLabel)
Expand Down Expand Up @@ -171,4 +170,4 @@ internal object InternalLeakCanary : LeakSentryListener {
heapDumpTrigger.onDumpHeapReceived()
}
}
}
}

0 comments on commit e4a16de

Please sign in to comment.