10

I have a bug with autofill manager, when I focus any input - it throws an exception:

W/System.err: java.lang.NullPointerException: activityToken
W/System.err: at android.os.Parcel.readException(Parcel.java:2011)
W/System.err: at android.os.Parcel.readException(Parcel.java:1951)
 at android.view.autofill.IAutoFillManager$Stub$Proxy.startSession(IAutoFillManager.java:397)
 at android.view.autofill.AutofillManager.startSessionLocked(AutofillManager.java:1012) W/System.err: at android.view.autofill.AutofillManager.notifyViewEntered(AutofillManager.java:734) android.view.autofill.AutofillManager.notifyViewEntered(AutofillManager.java:706)

I was able to fix it via adding a next code in the bases activity onCreate():

public static void preventViewAutoFill(@NonNull Window window) {
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
        final Method method;
        try {
            method = View.class.getMethod(AUTO_FILL_MANAGER_METHOD, Integer.TYPE);
        } catch (Exception ignore) {
            return;
        }
        if (method != null) {
            try {
                method.invoke(window.getDecorView(), IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);
            } catch (Exception ignore) {
            }
        }
    }
}

This fixed problem in all views except input inside the WebView. I have a WebView with input fields when user focus on any input inside a WebView application crash.

In there any way to fix this on the application layer or on the WebView side?

Application targeting 25 API, min 16.

2
  • 1
    i have this issue too but to make it worse its in a React Native app Commented Jan 25, 2019 at 14:28
  • Did you eventually find a solution to prevent this crash on WebView? Commented Aug 20, 2024 at 8:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.