Builder

Creates Policy instances. Methods whose names start with detect specify what problems we should look for. Methods whose names start with penalty specify what we should do when we detect a problem.

You can call as many detect and penalty methods as you like. Currently order is insignificant: all penalties apply to all detected problems.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun allowViolation(fragmentClass: Class<out Fragment>, violationClass: Class<out Violation>): FragmentStrictMode.Policy.Builder
fun allowViolation(fragmentClass: String, violationClass: Class<out Violation>): FragmentStrictMode.Policy.Builder

Allow the specified Fragment class to bypass penalties for the specified Violation, if detected.

Link copied to clipboard

Construct the Policy instance.

Link copied to clipboard

Detects cases, where a Fragment instance is reused, after it was previously removed from a FragmentManager.

Link copied to clipboard

Detects usage of the tag inside XML layouts.

Link copied to clipboard
Link copied to clipboard

Detects nested fragments that do not use the expected parent's childFragmentManager.

Link copied to clipboard

Throws an exception on violation. This penalty runs at the end of all enabled penalties so you'll still get to see logging or other violations before the exception is thrown.

Link copied to clipboard

Call OnViolationListener.onViolation for every violation. The listener will be called on the main thread of the fragment host.

Link copied to clipboard

Log detected violations to the system log.