public static boolean isAutofillAvailable(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { // Autofill Framework is only available on Android O and higher return false; } AutofillManager afm = context.getSystemService(AutofillManager.class); // Returns whether autofill is supported by device or and enabled for current user. return afm != null && afm.isAutofillSupported() && afm.isEnabled(); }
@RequiresApi(api = Build.VERSION_CODES.O) private void requestAutofillIfEmptyCardholder() { if (cardholderEditText.getText().toString().isEmpty()) { cardholderEditText.setAutofillHints(View.AUTOFILL_HINT_NAME); AutofillManager autofillManager = getSystemService(AutofillManager.class); if (autofillManager != null && autofillManager.isEnabled()) { autofillManager.requestAutofill(cardholderEditText); } } }