# Violation

Artifact: [androidx.fragment:fragment](https://developer.android.com/jetpack/androidx/releases/fragment) [View Source](https://cs.android.com/search?q=file:androidx/fragment/app/strictmode/Violation.kt+class:androidx.fragment.app.strictmode.Violation) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.4.0)

*** ** * ** ***


```
public abstract class Violation extends RuntimeException
```

<br />

|---|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||||
| ↳ | [kotlin.Throwable](https://developer.android.com/reference/java/lang/Throwable.html) ||||
|   | ↳ | [java.lang.Exception](https://developer.android.com/reference/java/lang/Exception.html) |||
|   |   | ↳ | [java.lang.RuntimeException](https://developer.android.com/reference/java/lang/RuntimeException.html) ||
|   |   |   | ↳ | [androidx.fragment.app.strictmode.Violation](https://developer.android.com/reference/androidx/fragment/app/strictmode/Violation) |

Known direct subclasses [FragmentReuseViolation](https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentReuseViolation), [FragmentTagUsageViolation](https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentTagUsageViolation), [RetainInstanceUsageViolation](https://developer.android.com/reference/androidx/fragment/app/strictmode/RetainInstanceUsageViolation), [SetUserVisibleHintViolation](https://developer.android.com/reference/androidx/fragment/app/strictmode/SetUserVisibleHintViolation), [TargetFragmentUsageViolation](https://developer.android.com/reference/androidx/fragment/app/strictmode/TargetFragmentUsageViolation), [WrongFragmentContainerViolation](https://developer.android.com/reference/androidx/fragment/app/strictmode/WrongFragmentContainerViolation), [WrongNestedHierarchyViolation](https://developer.android.com/reference/androidx/fragment/app/strictmode/WrongNestedHierarchyViolation)

|---|---|
| `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentReuseViolation` | See `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode.Policy.Builder#detectFragmentReuse()`. |
| `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentTagUsageViolation` | See `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode.Policy.Builder#detectFragmentTagUsage()`. |
| `https://developer.android.com/reference/androidx/fragment/app/strictmode/RetainInstanceUsageViolation` | See `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode.Policy.Builder#detectRetainInstanceUsage()`. |
| `https://developer.android.com/reference/androidx/fragment/app/strictmode/SetUserVisibleHintViolation` | See `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode.Policy.Builder#detectSetUserVisibleHint()`. |
| `https://developer.android.com/reference/androidx/fragment/app/strictmode/TargetFragmentUsageViolation` | See `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode.Policy.Builder#detectTargetFragmentUsage()`. |
| `https://developer.android.com/reference/androidx/fragment/app/strictmode/WrongFragmentContainerViolation` | See `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode.Policy.Builder#detectWrongFragmentContainer()`. |
| `https://developer.android.com/reference/androidx/fragment/app/strictmode/WrongNestedHierarchyViolation` | See `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode.Policy.Builder#detectWrongNestedHierarchy()`. |

Known indirect subclasses [GetRetainInstanceUsageViolation](https://developer.android.com/reference/androidx/fragment/app/strictmode/GetRetainInstanceUsageViolation), [GetTargetFragmentRequestCodeUsageViolation](https://developer.android.com/reference/androidx/fragment/app/strictmode/GetTargetFragmentRequestCodeUsageViolation), [GetTargetFragmentUsageViolation](https://developer.android.com/reference/androidx/fragment/app/strictmode/GetTargetFragmentUsageViolation), [SetRetainInstanceUsageViolation](https://developer.android.com/reference/androidx/fragment/app/strictmode/SetRetainInstanceUsageViolation), [SetTargetFragmentUsageViolation](https://developer.android.com/reference/androidx/fragment/app/strictmode/SetTargetFragmentUsageViolation)

|---|---|
| `https://developer.android.com/reference/androidx/fragment/app/strictmode/GetRetainInstanceUsageViolation` | See #`https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode.Policy.Builder#detectRetainInstanceUsage()`. |
| `https://developer.android.com/reference/androidx/fragment/app/strictmode/GetTargetFragmentRequestCodeUsageViolation` | See `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode.Policy.Builder#detectTargetFragmentUsage()`. |
| `https://developer.android.com/reference/androidx/fragment/app/strictmode/GetTargetFragmentUsageViolation` | See `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode.Policy.Builder#detectTargetFragmentUsage()`. |
| `https://developer.android.com/reference/androidx/fragment/app/strictmode/SetRetainInstanceUsageViolation` | See `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode.Policy.Builder#detectRetainInstanceUsage()`. |
| `https://developer.android.com/reference/androidx/fragment/app/strictmode/SetTargetFragmentUsageViolation` | See `https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode.Policy.Builder#detectTargetFragmentUsage()`. |

*** ** * ** ***

Root class for all FragmentStrictMode violations.

## Summary

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/fragment/app/Fragment` | `https://developer.android.com/reference/androidx/fragment/app/strictmode/Violation#getFragment()()` Gets the `https://developer.android.com/reference/androidx/fragment/app/Fragment` causing the Violation. |

### Inherited methods

From [kotlin.Throwable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html) `final void` `https://developer.android.com/reference/java/lang/Throwable.html#addSuppressed(java.lang.Throwable)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Throwable.html exception)` `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Throwable.html` `https://developer.android.com/reference/java/lang/Throwable.html#fillInStackTrace()()` `https://developer.android.com/reference/java/lang/Throwable.html` `https://developer.android.com/reference/java/lang/Throwable.html#getCause()()` `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` `@https://developer.android.com/reference/androidx/annotation/RecentlyNullable
https://developer.android.com/reference/java/lang/Throwable.html#getLocalizedMessage()()` `https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/java/lang/Throwable.html#getMessage()()` `@https://developer.android.com/reference/androidx/annotation/NonNull StackTraceElement[]` `@https://developer.android.com/reference/androidx/annotation/RecentlyNonNull
https://developer.android.com/reference/java/lang/Throwable.html#getStackTrace()()` `final @https://developer.android.com/reference/androidx/annotation/NonNull Throwable[]` `@https://developer.android.com/reference/androidx/annotation/RecentlyNonNull
https://developer.android.com/reference/java/lang/Throwable.html#getSuppressed()()` `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Throwable.html` `https://developer.android.com/reference/java/lang/Throwable.html#initCause(java.lang.Throwable)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Throwable.html cause)` `void` `https://developer.android.com/reference/java/lang/Throwable.html#printStackTrace()()` `void` `https://developer.android.com/reference/java/lang/Throwable.html#printStackTrace(java.io.PrintStream)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/PrintStream.html s)` `void` `https://developer.android.com/reference/java/lang/Throwable.html#printStackTrace(java.io.PrintWriter)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/PrintWriter.html s)` `void` `https://developer.android.com/reference/java/lang/Throwable.html#setStackTrace(java.lang.StackTraceElement[])(@https://developer.android.com/reference/androidx/annotation/NonNull StackTraceElement[] stackTrace)`

## Public methods

### getFragment

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.4.0)

```
public final @NonNull Fragment getFragment()
```

Gets the `https://developer.android.com/reference/androidx/fragment/app/Fragment` causing the Violation.