Compartir a través de


SaveInfo Class

Definition

Information used to indicate that an AutofillService is interested on saving the user-inputed data for future use, through a AutofillService#onSaveRequest(SaveRequest, SaveCallback) call.

[Android.Runtime.Register("android/service/autofill/SaveInfo", ApiSince=26, DoNotGenerateAcw=true)]
public sealed class SaveInfo : Java.Lang.Object, Android.OS.IParcelable, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/service/autofill/SaveInfo", ApiSince=26, DoNotGenerateAcw=true)>]
type SaveInfo = class
    inherit Object
    interface IParcelable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
SaveInfo
Attributes
Implements

Remarks

Information used to indicate that an AutofillService is interested on saving the user-inputed data for future use, through a AutofillService#onSaveRequest(SaveRequest, SaveCallback) call.

A SaveInfo is always associated with a FillResponse, and it contains at least two pieces of information:

<ol> <li>The type(s) of user data (like password or credit card info) that would be saved. <li>The minimum set of views (represented by their AutofillId) that need to be changed to trigger a save request. </ol>

Typically, the SaveInfo contains the same ids as the Dataset:

new FillResponse.Builder()
                  .addDataset(new Dataset.Builder()
                      .setValue(id1, AutofillValue.forText("homer"), createPresentation("homer")) // username
                      .setValue(id2, AutofillValue.forText("D'OH!"), createPresentation("password for homer")) // password
                      .build())
                  .setSaveInfo(new SaveInfo.Builder(
                      SaveInfo.SAVE_DATA_TYPE_USERNAME | SaveInfo.SAVE_DATA_TYPE_PASSWORD,
                      new AutofillId[] { id1, id2 }).build())
                  .build();

The save type flags are used to display the appropriate strings in the autofill save UI. You can pass multiple values, but try to keep it short if possible. In the above example, just SaveInfo.SAVE_DATA_TYPE_PASSWORD would be enough.

There might be cases where the AutofillService knows how to fill the screen, but the user has no data for it. In that case, the FillResponse should contain just the SaveInfo, but no Dataset Datasets:

new FillResponse.Builder()
                  .setSaveInfo(new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_PASSWORD,
                      new AutofillId[] { id1, id2 }).build())
                  .build();

There might be cases where the user data in the AutofillService is enough to populate some fields but not all, and the service would still be interested on saving the other fields. In that case, the service could set the SaveInfo.Builder#setOptionalIds(AutofillId[]) as well:

new FillResponse.Builder()
                  .addDataset(new Dataset.Builder()
                      .setValue(id1, AutofillValue.forText("742 Evergreen Terrace"),
                          createPresentation("742 Evergreen Terrace")) // street
                      .setValue(id2, AutofillValue.forText("Springfield"),
                          createPresentation("Springfield")) // city
                      .build())
                  .setSaveInfo(new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_ADDRESS,
                      new AutofillId[] { id1, id2 }) // street and  city
                      .setOptionalIds(new AutofillId[] { id3, id4 }) // state and zipcode
                      .build())
                  .build();

"TriggeringSaveRequest"><h3>Triggering a save request</h3>

The AutofillService#onSaveRequest(SaveRequest, SaveCallback) can be triggered after any of the following events: <ul> <li>The Activity finishes. <li>The app explicitly calls AutofillManager#commit(). <li>All required views become invisible (if the SaveInfo was created with the #FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE flag). <li>The user clicks a specific view (defined by Builder#setTriggerId(AutofillId). </ul>

But it is only triggered when all conditions below are met: <ul> <li>The SaveInfo associated with the FillResponse is not null neither has the #FLAG_DELAY_SAVE flag. <li>The AutofillValues of all required views (as set by the requiredIds passed to the SaveInfo.Builder constructor are not empty. <li>The AutofillValue of at least one view (be it required or optional) has changed (i.e., it's neither the same value passed in a Dataset, nor the initial value presented in the view). <li>There is no Dataset in the last FillResponse that completely matches the screen state (i.e., all required and optional fields in the dataset have the same value as the fields in the screen). <li>The user explicitly tapped the autofill save UI asking to save data for autofill. </ul>

"CustomizingSaveUI"><h3>Customizing the autofill save UI</h3>

The service can also customize some aspects of the autofill save UI: <ul> <li>Add a simple subtitle by calling Builder#setDescription(CharSequence). <li>Add a customized subtitle by calling Builder#setCustomDescription(CustomDescription). <li>Customize the button used to reject the save request by calling Builder#setNegativeAction(int, IntentSender). <li>Decide whether the UI should be shown based on the user input validation by calling Builder#setValidator(Validator). </ul>

Java documentation for android.service.autofill.SaveInfo.

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.

Fields

NegativeButtonStyleNever
Obsolete.

Style for the negative button of the save UI to never do the save operation.

PositiveButtonStyleContinue
Obsolete.

Style for the positive button of save UI to have next action before the save operation.

PositiveButtonStyleSave
Obsolete.

Style for the positive button of save UI to request the save operation.

SaveDataTypeDebitCard
Obsolete.

Type used when the FillResponse represents a debit card.

SaveDataTypeGenericCard
Obsolete.

Type used when the FillResponse represents a card that does not a specified card or cannot identify what the card is for.

SaveDataTypePaymentCard
Obsolete.

Type used when the FillResponse represents a payment card except for credit and debit cards.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Creator
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
DescribeContents()
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WriteToParcel(Parcel, ParcelableWriteFlags)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to