Android O has the feature to support Auto-filling for fields. Is there any way I can disable it for a specific application. That is I want to force my application not to use the auto-fill service.
Is it possible ?
To block autofill for an entire activity, use this in onCreate() of the activity:
getWindow() .getDecorView() .setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);
Is there any better method than this ?
Tap Advanced to expand the section. Tap Autofill service. Tap Autofill service again. Your screen will either display None or an app name, if you're using one.
An autofill service is an app that makes it easier for users to fill out forms by injecting data into the views of other apps. Autofill services can also retrieve user data from the views in an app and store it to use it at a later time.
Autofill is a dedicated framework introduced by Google that manages communication between the autofill service and apps on your Android device. The service works much like password managers, which take the stress out of forgetting passwords and fills out information in other apps using your data.
To start, you can reset your Autofill settings. Navigate to Settings > Autofill and turn Autofill and Accessibility off. Then restart your device and turn those settings back on.
Currently there is no direct way to disable the autofill for an entire application, since the autofill feature is View specific.
You can still try this way and call BaseActivity everywhere.
public class BaseActivity extends AppCompatActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); disableAutofill(); } @TargetApi(Build.VERSION_CODES.O) private void disableAutofill() { getWindow().getDecorView().setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS); } }
You can also force request autofill this way.
public void forceAutofill() { AutofillManager afm = context.getSystemService(AutofillManager.class); if (afm != null) { afm.requestAutofill(); } }
Note: At the moment autofill feature is only available in API 26 Android Oreo 8.0
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With