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?
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?
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);
}
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);
}
}