Stay organized with collections
Save and categorize content based on your preferences.
IncorrectContextUseViolation
class IncorrectContextUseViolation : Violation
Incorrect usage of Context
, such as obtaining a UI service from non-UI Context
instance.
Summary
Public constructors
IncorrectContextUseViolation
IncorrectContextUseViolation(
message: String,
originStack: Throwable)
Parameters |
message |
String: This value cannot be null . |
originStack |
Throwable: This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# IncorrectContextUseViolation\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nIncorrectContextUseViolation\n============================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/os/strictmode/IncorrectContextUseViolation \"View this page in Java\") \n\n```\nclass IncorrectContextUseViolation : Violation\n```\n\n|---|---|---|---------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||||\n| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html) |||\n| | ↳ | [android.os.strictmode.Violation](/reference/kotlin/android/os/strictmode/Violation) ||\n| | | ↳ | [android.os.strictmode.IncorrectContextUseViolation](#) |\n\nIncorrect usage of [Context](../../content/Context.html#), such as obtaining a UI service from non-UI [Context](../../content/Context.html#) instance.\n\nSummary\n-------\n\n| Public constructors ||\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [IncorrectContextUseViolation](#IncorrectContextUseViolation(kotlin.String,%20kotlin.Throwable))`(`message:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `originStack:` `[Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)`)` \u003cbr /\u003e |\n\n| Inherited functions ||\n|---|---|\n| From class [Violation](/reference/kotlin/android/os/strictmode/Violation) |----------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html) | [fillInStackTrace](/reference/kotlin/android/os/strictmode/Violation#fillInStackTrace())`()` \u003cbr /\u003e | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [hashCode](/reference/kotlin/android/os/strictmode/Violation#hashCode())`()` \u003cbr /\u003e | | [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html) | [initCause](/reference/kotlin/android/os/strictmode/Violation#initCause(kotlin.Throwable))`(`cause:` `[Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)?`)` \u003cbr /\u003e | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [setStackTrace](/reference/kotlin/android/os/strictmode/Violation#setStackTrace(kotlin.Array))`(`stackTrace:` `[Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\u003c[StackTraceElement](../../../java/lang/StackTraceElement.html#)!\u003e`)` \u003cbr /\u003e | ||\n\nPublic constructors\n-------------------\n\n### IncorrectContextUseViolation\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nIncorrectContextUseViolation(\n message: String, \n originStack: Throwable)\n```\n\n| Parameters ||\n|---------------|----------------------------------------------------------------------------------------------------------------------|\n| `message` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): This value cannot be `null`. |\n| `originStack` | [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html): This value cannot be `null`. |"]]