Have you ever wondered how Android "guess" what to enter in the form field - login, password or phone number? Behind this magic is a mechanism autofillHintsthat few users know about, but is actively used by developers. This is not just a convenient feature: properly configured autofill suggestions save time, reduce the number of typing errors and even increase security (for example, preventing phishing through fake input fields).

In this article we will understand what they are autofillHints on a technical level, how they are integrated into Android applications, and why the average user should pay attention to these โ€œinvisibleโ€ marks. You'll learn how to check if your app supports autofill, how to manually manage saved data, and why some fields remain blank even though autofill is enabled. And for developers, we will provide current code examples and a table of supported values autofillHints in the latest versions of Android.

Spoiler: if you often encounter the fact that a password manager (for example, Google Password Manager or 1Password) does not offer saved data in the required field, the problem is more likely just in the absence or incorrect autofillHints. And this can be fixed!

What are autofillHints in Android: definition and principle of operation

AutofillHints (autofill hints) are special attributes that developers add to input fields in Android applications to help the system or third-party password managers (for example, Bitwarden, KeePassDX) correctly identify the data type. For example, when you see a field for email, but Android does not offer saved addresses, most likely this field is simply not specified autofillHints="emailAddress".

The mechanism works like this:

  • ๐Ÿ“ฑ The application marks the input field with an attribute android:autofillHints (for example, username, password, creditCardNumber).
  • ๐Ÿ” Autofill service (built-in Android or third-party) scans the screen for the presence of such labels.
  • ๐Ÿ“ The User offers saved data corresponding to the type of field (for example, logins for usernamepasswords for password).

Without autofillHints the autofill service has to โ€œguessโ€ the field type based on the context (for example, if there is the text โ€œPasswordโ€ next to the field), which often leads to errors. For example, a field for a phone number may be recognized as a โ€œusernameโ€ if not specified. autofillHints="phone".

๐Ÿ“Š How often do you use autofill on Android?
All the time
Sometimes
Occasionally
Never

It is important to understand that autofillHints is not the same as inputType (for example, textPassword). The latter determines how the field will be displayed on the screen (for example, hide characters for a password), but autofillHints โ€”how the system should interpret the entered data for autofill. These attributes are often used together, but they do different things. functions.

Why are autofillHints needed: benefits for users and developers

For ordinary users autofillHints this is first of all convenience and securityHere are a few key advantages:

  • โฑ๏ธ Saving time: no need to manually enter logins, passwords or card details - the system offers saved options.
  • ๐Ÿ”’ Phishing protection: if the field is not marked correctly autofillHints, the password manager will not substitute the data, which may be a sign of a fraudulent site/application.
  • ๐Ÿ“ฑ Cross-platform synchronization: autofill data (for example, from Google Password Manager) is available on all devices with your account.
  • ๐Ÿ”„ Fewer errors: eliminates typos when manually entering complex passwords or numbers maps.

For developers autofillHints is a way to improve user experience (UX) and comply with modern security standards. For example, Google Play Console can issue warnings if the application does not have autofill prompts for critical fields (for example, payment forms). correct autofillHints help:

  • ๐Ÿ“Š Increase conversion: users fill out forms faster (for example, registration or placing an order).
  • ๐Ÿ›ก๏ธ Reduce the number support: fewer requests like โ€œautofill does not work.โ€
  • โšก Improve accessibility: it is easier for people with disabilities to interact with forms.
๐Ÿ’ก

If you are developing an application with payment forms, be sure to use autofillHints="creditCardNumber", creditCardExpirationDate i creditCardSecurityCodeThis is not only convenient for users, but also complies with PCI DSS requirements (standard). payment card industry data security).

There is also a downside: if autofillHints is entered incorrectly, this can lead to:

  • ๐Ÿšซ Suggestion of irrelevant data (for example, a password in the name field).
  • ๐Ÿ”“ Refusal of the password manager to save data (if the field is not recognized).
  • ๐Ÿ›‘ Validation errors (for example, if a phone number is substituted in the email field).

List of supported autofillHints in Android: table of values

Android supports dozens of standard values autofillHintscovering most scenarios - from authorization before placing orders. Below is a table with the main categories and examples. The full list can be found in official documentation (valid for Android 10 and later).

Category Value autofillHints Example of use
Authorization username Field for login or user name
Authorization password Field for password (often used together with inputType="textPassword")
Contact emailAddress Field for email addresses
Contact phone Field for phone number
Payment details creditCardNumber Bank card number
Payment details creditCardExpirationDate Card expiration date (for example, โ€œMM/YYโ€)
Address postalAddress Full postal address
Address postalCode Postal code

Some values can be combined separated by a comma if the field can accept several data types. For example:

<EditText

android:autofillHints="username, emailAddress"

... />

Android 12 and later introduced advanced hints for biometric authentication, such as biometricWeak (for example, for Face ID) and biometricStrong (for fingerprint). This allows password managers to offer more accurate unlocking options.

Which autofillHints are used for two-factor authentication (2FA)?

For verification code entry fields (SMS or TOTP), it is recommended to use autofillHints="smsOtp" or oneTimeCodeThis helps autofill services (for example, Google Messages) automatically insert the code from SMS. Android 13 adds support totpSecret for TOTP keys (for example, in Google Authenticator).

How to check if an application supports autofillHints

If you are a user and have noticed that autofill does not work in some application, you can check for yourself whether it is to blame missing autofillHints. Here are the step-by-step guide:

1. Open the application and go to the form (for example, authorization).

2. Touch the input field and hold your finger for 1-2 seconds.

3. In the menu that appears, select โ€œAutofillโ€ (or โ€œAutofillโ€)

4. See if the system offers saved data. If not, most likely the field is missing autofillHints.-->

For deeper diagnostics, you can use the developer tools:

  1. Connect the device to the PC and turn it on USB Debugging in Settings โ†’ System โ†’ For Developers.
  2. Open Android Studio and run Layout Inspector (Tools โ†’ Layout Inspector).
  3. Select the input field in the inspector and check the presence of the attribute autofillHints.

If you are not a developer, but want to report an autofill problem to the app creators, use the template:

"Hello! Autofill for the field [describe the field, for example, โ€œemail during registration"] does not work in your application [name] Please add an attribute android:autofillHints="emailAddress" for this. fields. Thank you!โ€

Many popular applications (for example, Twitter, Instagram) are already optimized for autofill, but in lesser-known services or banking applications autofillHints may be absent due to strict security requirements.

How to set up autofillHints for your application: instructions for developers

If you are developing an Android application, adding autofillHints takes only a few minutes, but significantly improves the user experience. Here is a basic example for the authorization form:

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="vertical">

<EditText

android:id="@+id/emailField"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Email"

android:autofillHints="emailAddress"

android:inputType="textEmailAddress"/>

<EditText

android:id="@+id/passwordField"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Password"

android:autofillHints="password"

android:inputType="textPassword"/>

<Button

android:id="@+id/loginButton"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Login"/>

</LinearLayout>

To dynamically add autofillHints from code (for example, if the field type is defined at runtime), use:

editText.setAutofillHints(View.AUTOFILL_HINT_EMAIL_ADDRESS);

// or for several values:

editText.setAutofillHints(View.AUTOFILL_HINT_USERNAME, View.AUTOFILL_HINT_EMAIL_ADDRESS);

Do not forget about the following nuances:

  • ๐Ÿ”น For fields with inputType="textPassword" required specify autofillHints="password", otherwise password managers may ignore them.
  • ๐Ÿ”น If a field can accept several data types (for example, login or email), list them separated by commas in XML or use several constants in setAutofillHints.
  • ๐Ÿ”น For fields with custom validation (for example, โ€œUsername must contain only Latin charactersโ€), specify the most close autofillHintseven if the format is non-standard.
๐Ÿ’ก

Always test autofill on a real device! The emulator may not show problems associated with specific autofill services (for example, LastPass or 1Password).

For complex forms (for example, multi-page registration), use android:importantForAutofill with values:

  • yes โ€” a field critical for autofill (for example, email).
  • no โ€” the field does not need to be autofilled (for example, captcha).
  • noExcludeDescendants โ€” autofill is disabled for this container, but is allowed for nested fields.

Common problems with autofillHints and how to solve them

Even if autofillHints are specified correctly, autofill may not work. Here are the problems and their solutions:

Problem Possible reason Solution
Password manager does not offer data Missing autofillHints or specified incorrectly Add the correct one autofillHints (see table above)
Autofill works only after manual entry Field marked as importantForAutofill="no" Make sure the attribute is set to yes or not specified
Irrelevant data offered (for example, password in the name field) Invalid autofillHints or conflict c inputType Check the combination autofillHints and inputType
Autofill does not work in WebView No autofill support for web forms Use android:autofillHints for input fields in the native interface

Pay special attention to the following scenarios:

  • ๐Ÿ”น Fields with masks (for example, for a phone number in the format +7 (XXX) XXX-XX-XX), use autofillHints="phone", even if the format is non-standard.
  • ๐Ÿ”น Dynamic forms (where fields are added programmatically). Don't forget to call setAutofillHints after creating the field.
  • ๐Ÿ”น Fields with custom keyboard. data-i="210">corresponds inputType corresponds autofillHints (for example, for autofillHints="creditCardNumber" use inputType="number").
๐Ÿ’ก

If autofill does not work in WebView, try use android:autofillHints="webDomain" for a URL field or webUsername/webPassword for authorization forms.

To debug problems with autofill, enable logging:

adb shell setprop log.tag.AutofillManager DEBUG

adb logcat | grep Autofill

โš ๏ธ Attention: Logs may contain sensitive data (for example, partially masked passwords.

Security and autofillHints: how to protect yourself from phishing

AutofillHints not only make life easier for users, but also play an important role in security Fraudsters often create fake authorization forms where the fields are not marked correctly autofillHintsto. trick password managers. Here's how it works and how to protect yourself:

๐Ÿ” Phishing signs associated with autofillHints:

  • ๐Ÿšฉ The password field does not offer saved options (no autofillHints="password").
  • ๐Ÿšฉ There is no email/login prompt in the login form (autofillHints="username" or emailAddress).
  • ๐Ÿšฉ The field for the โ€œsecret codeโ€ does not have autofillHints="smsOtp"although it should.

๐Ÿ›ก๏ธ How to protect yourself:

  • ๐Ÿ”’ Always check whether your password manager offers data for fields. If not, this is a reason to be wary.
  • ๐Ÿ” Use applications that show autofillHints for fields (for example, Autofill Inspector from F-Droid).
  • ๐Ÿ“ฑ Turn on the option โ€œShow auto-fill hintsโ€ in the Android settings (Settings โ†’ System โ†’ Language and input โ†’ Advanced โ†’ Autofill).

Developers are recommended:

  • ๐Ÿ”น Always mark the authorization and payment fields as correct autofillHints.
  • ๐Ÿ”น Use android:importantForAutofill="no" for fields that should not be autofilled (for example, captcha).
  • ๐Ÿ”น Test the application with popular password managers (Bitwarden, 1Password, KeePassDX).
โš ๏ธ Attention: Some banking applications intentionally disable autofill for fields with passwords or PIN codes for security reasons. It is normal if this behavior occurs documented in the application policy.

FAQ: Frequently asked questions about autofillHints in Android

Is it possible to add autofillHints to an already published application without updating?

No, autofillHints is part of the app's markup or code. To add or change tooltips, you need to release an update. However, users can manually save data for fields without autofillHints via the autocomplete menu (holding your finger on the input field).

Why does autocomplete work in one application, but not in another?

This depends on two factors: (1) whether the application supports data-i="251">for its fields, and (2) whether the autofill service is enabled in the Android settings. Check: autofillHints for your fields, and (2) whether the autofill service is enabled in Android settings. Check:

- Whether the field is open for autofill (importantForAutofill="yes").

- Whether the field is valid autofillHints.

- Is autofill enabled in Settings โ†’ System โ†’ Language and input โ†’ Advanced โ†’ Autofill.

Which autofill service is best to use on Android?

The choice depends on your needs:

- Google Password Manager (built-in) - convenient for the Google ecosystem, synchronized with your account.

- Bitwarden or 1Password - more functions, cross-platform, TOTP support.

- KeePassDX - for lovers of open source software and local storage.

They all support autofillHintsbut may interpret non-standard values differently.

Is it possible to disable autofillHints for a specific field?

Yes, use android:importantForAutofill="no" or just leave it out autofillHints. You can also completely disable autofill for Activity via android:windowSoftInputMode="stateAlwaysHidden|adjustPan" in the manifest, but this is an extreme measure.

Are autofillHints supported in Instant Apps?

Yes, autofillHints work in Instant Apps the same way as in regular applications. However, some password managers may limit autofill for instant applications for security reasons.