16: Skipping password saving since the user is likely prompted with Android Autofill

Viewed 577

I am integrating google smart lock in my android application but in some devices i am getting this error when trying to save credentials to google. I am using following code to save credentials -

 Credential credential = new Credential.Builder(email)
                                       .setPassword(password)
                                       .build();
 saveCredentials(credential);

After search on google for this solution found that need to disable auto-fill feature in application to save the password.

Try 1 - Put the following code in activity for commit autofillmager in specific activity and disable autofill. But it is not working.

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

    AutofillManager autofillManager = getSystemService(AutofillManager.class);
    autofillManager.commit();

    getWindow()
            .getDecorView()
            .setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);
 }

Try 2 - Put following in properties in EditText

 android:longClickable="false"

longClickable should stop autofill but it is not working.

 android:importantForAutofill="no"

Also try with importantForAutoFill but it is also not working.

1 Answers

I removed all the code for manual saving and just added android:autofillHints="username" for login field and android:autofillHints="password" for password field in the sign in form. Password saving dialog appears all the same, thanks to the Android's Autofill service.

Related