Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling Android O auto-fill service for an application

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 ?

like image 287
jgm Avatar asked Aug 17 '17 09:08

jgm


People also ask

How do I stop apps from auto filling?

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.

What is autofill service in Android?

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.

What is auto fill on my phone?

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.

Why is auto fill not working on Android?

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.


1 Answers

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!

like image 91
albeee Avatar answered Sep 21 '22 03:09

albeee