This filter rejects characters in the user name that are not compatible with Google login. It is slightly less restrictive than the above filter in that it allows [a-zA-Z0-9._-+].
This method is called when the buffer is going to replace the range dstart … dend of dest with the new text from the range start … end of source. Returns the CharSequence that we want placed there instead, including an empty string if appropriate, or null to accept the original replacement. Be careful to not to reject 0-length replacements, as this is what happens when you delete text.
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,["# LoginFilter.UsernameFilterGeneric\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nUsernameFilterGeneric\n=====================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/text/LoginFilter.UsernameFilterGeneric \"View this page in Java\") \n\n```\nopen class UsernameFilterGeneric : LoginFilter\n```\n\n|---|---|-----------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||\n| ↳ | [android.text.LoginFilter](/reference/kotlin/android/text/LoginFilter) ||\n| | ↳ | [android.text.LoginFilter.UsernameFilterGeneric](#) |\n\n*** ** * ** ***\n\n| **This class was deprecated in API level 30.**\n|\n| Deprecated in Java.\n\nThis filter rejects characters in the user name that are not compatible with Google login. It is slightly less restrictive than the above filter in that it allows \\[a-zA-Z0-9._-+\\].\n\nSummary\n-------\n\n| Public constructors ||\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [UsernameFilterGeneric](#UsernameFilterGeneric())`()` \u003cbr /\u003e |\n| [UsernameFilterGeneric](#UsernameFilterGeneric(kotlin.Boolean))`(`appendInvalid:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` \u003cbr /\u003e |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|\n| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isAllowed](#isAllowed(kotlin.Char))`(`c:` `[Char](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char/index.html)`)` \u003cbr /\u003e |\n\n| Inherited functions ||\n|---|---|\n| From class [LoginFilter](/reference/kotlin/android/text/LoginFilter) |------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)! | [filter](/reference/kotlin/android/text/LoginFilter#filter(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20android.text.Spanned,%20kotlin.Int,%20kotlin.Int))`(`source:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`, `start:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `end:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `dest:` `[Spanned](/reference/kotlin/android/text/Spanned)!`, `dstart:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `dend:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` This method is called when the buffer is going to replace the range `dstart ... dend` of `dest` with the new text from the range `start ... end` of `source`. Returns the CharSequence that we want placed there instead, including an empty string if appropriate, or `null` to accept the original replacement. Be careful to not to reject 0-length replacements, as this is what happens when you delete text. \u003cbr /\u003e | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onInvalidCharacter](/reference/kotlin/android/text/LoginFilter#onInvalidCharacter(kotlin.Char))`(`c:` `[Char](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char/index.html)`)` Called whenever we encounter an invalid character. \u003cbr /\u003e | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onStart](/reference/kotlin/android/text/LoginFilter#onStart())`()` Called when we start processing filter. \u003cbr /\u003e | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onStop](/reference/kotlin/android/text/LoginFilter#onStop())`()` Called when we're done processing filter \u003cbr /\u003e | ||\n\nPublic constructors\n-------------------\n\n### UsernameFilterGeneric\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nUsernameFilterGeneric()\n``` \n\n### UsernameFilterGeneric\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nUsernameFilterGeneric(appendInvalid: Boolean)\n```\n\nPublic methods\n--------------\n\n### isAllowed\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun isAllowed(c: Char): Boolean\n```\n\n**Deprecated:** *Deprecated in Java.*"]]