Share via


View.IsImportantForAutofill Property

Definition

Hints the Android System whether the android.app.assist.AssistStructure.ViewNode associated with this view is considered important for autofill purposes.

public bool IsImportantForAutofill { [Android.Runtime.Register("isImportantForAutofill", "()Z", "", ApiSince=26)] get; }
[<get: Android.Runtime.Register("isImportantForAutofill", "()Z", "", ApiSince=26)>]
member this.IsImportantForAutofill : bool

Property Value

whether the view is considered important for autofill.

Attributes

Remarks

Hints the Android System whether the android.app.assist.AssistStructure.ViewNode associated with this view is considered important for autofill purposes.

Generally speaking, a view is important for autofill if: <ol> <li>The view can be autofilled by an android.service.autofill.AutofillService. <li>The view contents can help an android.service.autofill.AutofillService determine how other views can be autofilled. <ol>

For example, view containers should typically return false for performance reasons (since the important info is provided by their children), but if its properties have relevant information (for example, a resource id called credentials, it should return true. On the other hand, views representing labels or editable fields should typically return true, but in some cases they could return false (for example, if they're part of a "Captcha" mechanism).

The value returned by this method depends on the value returned by #getImportantForAutofill():

<ol> <li>if it returns #IMPORTANT_FOR_AUTOFILL_YES or #IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, then it returns true<li>if it returns #IMPORTANT_FOR_AUTOFILL_NO or #IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS, then it returns false<li>if it returns #IMPORTANT_FOR_AUTOFILL_AUTO, then it uses some simple heuristics that can return true in some cases (like a container with a resource id), but false in most. <li>otherwise, it returns false. </ol>

The behavior of importances depends on Android version: <ol> <li>For android.os.Build.VERSION_CODES#TIRAMISU and below: <ol> <li>When a view is considered important for autofill: <ol> <li>The view might automatically trigger an autofill request when focused on. <li>The contents of the view are included in the ViewStructure used in an autofill request. </ol> <li>On the other hand, when a view is considered not important for autofill: <ol> <li>The view never automatically triggers autofill requests, but it can trigger a manual request through AutofillManager#requestAutofill(View). <li>The contents of the view are not included in the ViewStructure used in an autofill request, unless the request has the #AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS flag. </ol> </ol> <li>For android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE and above: <ol> <li>The system uses importance, along with other view properties and other optimization factors, to determine if a view should trigger autofill on focus. <li>The contents of #IMPORTANT_FOR_AUTOFILL_AUTO, #IMPORTANT_FOR_AUTOFILL_YES, #IMPORTANT_FOR_AUTOFILL_NO, #IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, and #IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS views will be included in the ViewStructure used in an autofill request. </ol> </ol>

Java documentation for android.view.View.isImportantForAutofill().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to