我知道在 8.0 中,首选自动填充,但我想强制使用 Google Smart Lock 保存对话框。在实施时出现此错误:
{Status{statusCode=The Credentials API's save confirmation dialog has been disabled to avoid conflicts with the Android Autofill feature. This choice may be overridden via AuthCredentialsOptions.Builder.forceEnableSaveDialog()., resolution=null}}
但在 Android文档中,没有办法解决这个问题。在 Google 搜索或文档中的搜索中找不到此forceEnableSaveDialog()
方法。
有谁知道如何在 8.0 设备上强制执行此对话框?我希望我的应用程序在不同版本中的行为保持一致。
SaveCredentials 代码片段:
mCredentialsApiClient = new GoogleApiClient.Builder(Xamarin.Forms.Forms.Context)
.AddConnectionCallbacks((obj) =>
{
var credendial = new Credential.Builder(userName).SetPassword(password).Build();
Auth.CredentialsApi.Save(mCredentialsApiClient, credendial).SetResultCallback(new ResultCallback<IResult>((obj2) =>
{
Print("Saved");
if (obj2.Status.IsSuccess)
{
Print("Credentails successfully saved with Google Smart Lock");
}
else if (obj2.Status.StatusCode == CommonStatusCodes.ResolutionRequired)
{
obj2.Status.StartResolutionForResult(CrossCurrentActivity.Current.Activity, obj2.Status.StatusCode);
}
}));
})
.AddOnConnectionFailedListener(NotConnected)
.AddApi(Auth.CREDENTIALS_API)
.Build();
mCredentialsApiClient.Connect();
这是 Xamarin 中的 Android。相同的方法和一切,只使用 C#