1

I want to get the user to auto-fill framework settings screen to enable the AutoFill framework to auto-fill the login form in third-party apps.

So, how can I get the user programmatically to the auto-fill settings screen in Oreo devices?

ardiien
  • 767
  • 6
  • 26
Happy
  • 1,031
  • 10
  • 26

2 Answers2

2

After a long search i have found answer from gitup projects.

The code to get the user to auto fill settings screen pro-grammatically is below

   if (mAutofillManager != null && !mAutofillManager.hasEnabledAutofillServices()) {
        Intent intent = new Intent(Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE);
        intent.setData(Uri.parse("package:com.example.android"));
        startActivityForResult(intent, REQUEST_CODE_SET_DEFAULT);
    }
Happy
  • 1,031
  • 10
  • 26
0

Prerequistes:

User must to Enable the Autofill service. Settings > System > Languages & input > Advanced > Input assistance > Autofill service.

1.Providing hints for autofill

autofill service classify the data correctly by providing the meaning of each view that could be autofillable, such as views representing usernames and passwords.

xml :

android:autofillHints="AUTOFILL_HINT_USERNAME"

or

Java :

editText.setAutofillHints(View.AUTOFILL_HINT_USERNAME);

2. Force an autofill request

AutofillManager afm = getSystemService(AutofillManager.class);
if (afm != null) {
    if (afm.isEnabled()) {   //for afmanager is enabled or not
        afm.requestAutofill(editText);
    }
}
Raj
  • 477
  • 5
  • 20
  • My question is, can we take the user to auto fill settings screen pro-grammatically as below for accessibility startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)); – Happy Nov 14 '17 at 06:13
  • Is it possible to check if it's enabled for a specific type, such as a phone number? – android developer Feb 26 '20 at 10:22
  • The answer by https://stackoverflow.com/users/2838776/happy is correct, this answer does not contain the piece of code that creates an intent to change autofill service provider. – Ziv Kesten Feb 15 '23 at 08:08