From 674561a613b45485d20a6300dbf703a2ccfee43d Mon Sep 17 00:00:00 2001 From: Nate Fischer Date: Thu, 26 Oct 2017 12:28:01 -0700 Subject: WebView: document requirement for Activity Context No change to logic, documentation change only. WebView requires an Activity Context in order to work properly (several features depend on this). This CL documents this in each WebView constructor by specifying "Activity Context" for the Context param. This CL also adds a note in WebView(Context) to explain the importance of an Activity Context. Fixes: 67945912 Test: make -j40 docs (manually verify it looks good) Change-Id: I6f84093f7ce39f6bd924fd6e27737f047348d8a4 --- core/java/android/webkit/WebView.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 3a4bfd686333..bc161bb2d011 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -535,9 +535,13 @@ public class WebView extends AbsoluteLayout } /** - * Constructs a new WebView with a Context object. + * Constructs a new WebView with an Activity Context object. * - * @param context a Context object used to access application assets + *

Note: WebView should always be instantiated with an Activity Context. + * If instantiated with an Application Context, WebView will be unable to provide several + * features, such as JavaScript dialogs and autofill. + * + * @param context an Activity Context to access application assets */ public WebView(Context context) { this(context, null); @@ -546,7 +550,7 @@ public class WebView extends AbsoluteLayout /** * Constructs a new WebView with layout parameters. * - * @param context a Context object used to access application assets + * @param context an Activity Context to access application assets * @param attrs an AttributeSet passed to our parent */ public WebView(Context context, AttributeSet attrs) { @@ -556,7 +560,7 @@ public class WebView extends AbsoluteLayout /** * Constructs a new WebView with layout parameters and a default style. * - * @param context a Context object used to access application assets + * @param context an Activity Context to access application assets * @param attrs an AttributeSet passed to our parent * @param defStyleAttr an attribute in the current theme that contains a * reference to a style resource that supplies default values for @@ -569,7 +573,7 @@ public class WebView extends AbsoluteLayout /** * Constructs a new WebView with layout parameters and a default style. * - * @param context a Context object used to access application assets + * @param context an Activity Context to access application assets * @param attrs an AttributeSet passed to our parent * @param defStyleAttr an attribute in the current theme that contains a * reference to a style resource that supplies default values for @@ -586,7 +590,7 @@ public class WebView extends AbsoluteLayout /** * Constructs a new WebView with layout parameters and a default style. * - * @param context a Context object used to access application assets + * @param context an Activity Context to access application assets * @param attrs an AttributeSet passed to our parent * @param defStyleAttr an attribute in the current theme that contains a * reference to a style resource that supplies default values for @@ -611,7 +615,7 @@ public class WebView extends AbsoluteLayout * time. This guarantees that these interfaces will be available when the JS * context is initialized. * - * @param context a Context object used to access application assets + * @param context an Activity Context to access application assets * @param attrs an AttributeSet passed to our parent * @param defStyleAttr an attribute in the current theme that contains a * reference to a style resource that supplies default values for -- cgit v1.2.3-59-g8ed1b