FragmentStrictMode

public final class FragmentStrictMode
extends Object

java.lang.Object
   ↳ androidx.fragment.app.strictmode.FragmentStrictMode


FragmentStrictMode is a tool which detects things you might be doing by accident and brings them to your attention so you can fix them. Basically, it's a version of StrictMode specifically for fragment-related issues.

You can decide what should happen when a violation is detected. For example, using FragmentStrictMode.Policy.Builder.penaltyLog() you can watch the output of adb logcat while you use your application to see the violations as they happen.

Summary

Nested classes

interface FragmentStrictMode.OnViolationListener

When #FragmentStrictMode.Policy.Builder.penaltyListener(FragmentStrictMode.OnViolationListener) is enabled, the listener is called when a violation occurs. 

class FragmentStrictMode.Policy

FragmentStrictMode policy applied to a certain FragmentManager (or globally). 

Public methods

static FragmentStrictMode.Policy getDefaultPolicy()

Returns the current default policy.

static void setDefaultPolicy(FragmentStrictMode.Policy policy)

Sets the policy for what actions should be detected, as well as the penalty if such actions occur.

Inherited methods

Public methods

getDefaultPolicy

public static FragmentStrictMode.Policy getDefaultPolicy ()

Returns the current default policy.

Returns
FragmentStrictMode.Policy

setDefaultPolicy

public static void setDefaultPolicy (FragmentStrictMode.Policy policy)

Sets the policy for what actions should be detected, as well as the penalty if such actions occur.

Parameters
policy FragmentStrictMode.Policy: the policy to put into place