From f02f846439b3e01adc34bde4d56ced1304ac8d84 Mon Sep 17 00:00:00 2001
From: Nate Fischer
block for consistency. Other than the modifiedblock, this has no reader-visible change, it merely complies with best practices from Android API guidelines. Bug: 65381884 Test: make docs (and manually compare before/after for differences) Change-Id: I2f911a43b88a8897d9d1b5c7945360580491883d --- core/java/android/webkit/WebView.java | 67 ++++++++++++++++------------------- 1 file changed, 31 insertions(+), 36 deletions(-) (limited to 'core/java/android/webkit/WebView.java') diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index f918cadde87c..e92f71e6d650 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -75,18 +75,22 @@ import java.util.Map; * can roll your own web browser or simply display some online content within your Activity. * It uses the WebKit rendering engine to display * web pages and includes methods to navigate forward and backward - * through a history, zoom in and out, perform text searches and more. + * through a history, zoom in and out, perform text searches and more. + * *- *Note that, in order for your Activity to access the Internet and load web pages * in a WebView, you must add the {@code INTERNET} permissions to your - * Android Manifest file:
- *<uses-permission android:name="android.permission.INTERNET" />+ * Android Manifest file: + * + *+ * {@code* *} + * This must be a child of the {@code
+ * element. * *} - * element.For more information, read - * Building Web Apps in WebView.
+ * Building Web Apps in WebView. * *Basic usage
* @@ -103,17 +107,19 @@ import java.util.Map; * Intent intent = new Intent(Intent.ACTION_VIEW, uri); * startActivity(intent); *See {@link android.content.Intent} for more information.
+ *See {@link android.content.Intent} for more information. * *
To provide a WebView in your own Activity, include a {@code
+ * android.app.Activity#onCreate(Bundle) onCreate()}: + * *} in your layout, * or set the entire Activity window as a WebView during {@link - * android.app.Activity#onCreate(Bundle) onCreate()}: * WebView webview = new WebView(this); * setContentView(webview); ** - *Then load the desired web page:
+ *Then load the desired web page: + * *
* // Simplest usage: note that an exception will NOT be thrown * // if there is an error loading this page (see below). @@ -128,7 +134,7 @@ import java.util.Map; ** *A WebView has several customization points where you can add your - * own behavior. These are:
+ * own behavior. These are: * *
Here's a more complicated example, showing error handling, - * settings, and progress notification:
+ * settings, and progress notification: * ** // Let's display the progress in the activity title bar, like the @@ -183,23 +189,23 @@ import java.util.Map; * *To enable the built-in zoom, set * {@link #getSettings() WebSettings}.{@link WebSettings#setBuiltInZoomControls(boolean)} - * (introduced in API level {@link android.os.Build.VERSION_CODES#CUPCAKE}).
+ * (introduced in API level {@link android.os.Build.VERSION_CODES#CUPCAKE}). + * *NOTE: Using zoom if either the height or width is set to * {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} may lead to undefined behavior - * and should be avoided.
+ * and should be avoided. * *Cookie and window management
* *For obvious security reasons, your application has its own * cache, cookie store etc.—it does not share the Browser * application's data. - *
* *By default, requests by the HTML to open new windows are * ignored. This is true whether they be opened by JavaScript or by * the target attribute on a link. You can customize your * {@link WebChromeClient} to provide your own behavior for opening multiple windows, - * and render them in whatever manner you want.
+ * and render them in whatever manner you want. * *The standard behavior for an Activity is to be destroyed and * recreated when the device orientation or any other configuration changes. This will cause @@ -208,7 +214,7 @@ import java.util.Map; * changes, and then just leave the WebView alone. It'll automatically * re-orient itself as appropriate. Read Handling Runtime Changes for - * more information about how to handle configuration changes during runtime.
+ * more information about how to handle configuration changes during runtime. * * *Building web pages to support different screen densities
@@ -220,15 +226,15 @@ import java.util.Map; * height and width are defined in terms of screen pixels will appear larger on the lower density * screen and smaller on the higher density screen. * For simplicity, Android collapses all actual screen densities into three generalized densities: - * high, medium, and low. + * high, medium, and low. *By default, WebView scales a web page so that it is drawn at a size that matches the default * appearance on a medium density screen. So, it applies 1.5x scaling on a high density screen * (because its pixels are smaller) and 0.75x scaling on a low density screen (because its pixels * are bigger). * Starting with API level {@link android.os.Build.VERSION_CODES#ECLAIR}, WebView supports DOM, CSS, * and meta tag features to help you (as a web developer) target screens with different screen - * densities.
- *Here's a summary of the features you can use to handle different screen densities:
+ * densities. + *Here's a summary of the features you can use to handle different screen densities: *
* <link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio:1.5)" href="hdpi.css" />*
The {@code hdpi.css} stylesheet is only used for devices with a screen pixel ration of 1.5, - * which is the high density pixel ratio.
+ * which is the high density pixel ratio. *In order to support inline HTML5 video in your application you need to have hardware * acceleration turned on. - *
* *@@ -284,7 +287,6 @@ import java.util.Map; * for the height none of the WebView's parents should use a * {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} layout height since that could result in * incorrect sizing of the views. - *
* *Setting the WebView's height to {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} * enables the following behaviors: @@ -294,13 +296,11 @@ import java.util.Map; *
* Using a layout width of {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} is not * supported. If such a width is used the WebView will attempt to use the width of the parent * instead. - *
* ** Data will only be uploaded for a given app if the user has consented AND the app has not opted * out. - *
* ** If Safe Browsing is enabled, WebView will block malicious URLs and present a warning UI to the * user to allow them to navigate back safely or proceed to the malicious page. - *
** The recommended way for apps to enable the feature is putting the following tag in the manifest: - *
**
* <meta-data android:name="android.webkit.WebView.EnableSafeBrowsing" * android:value="true" /> *- * * */ // Implementation notes. @@ -1197,11 +1192,11 @@ public class WebView extends AbsoluteLayout * immediately be reflected visually by subsequent {@link WebView#onDraw} invocations. The * {@link VisualStateCallback} provides a mechanism to notify the caller when the contents of * the DOM at the current time are ready to be drawn the next time the {@link WebView} - * draws. + * draws. * *
The next draw after the callback completes is guaranteed to reflect all the updates to the * DOM up to the point at which the {@link VisualStateCallback} was posted, but it may also - * contain updates applied after the callback was posted.
+ * contain updates applied after the callback was posted. * *The state of the DOM covered by this API includes the following: *
To guarantee that the {@link WebView} will successfully render the first frame * after the {@link VisualStateCallback#onComplete} method has been called a set of conditions @@ -1230,11 +1225,11 @@ public class WebView extends AbsoluteLayout * {@link AbsoluteLayout.LayoutParams LayoutParams}'s width and height need to be set to fixed * values and must be made {@link View#VISIBLE VISIBLE} from the * {@link VisualStateCallback#onComplete} method. - *
+ * * *When using this API it is also recommended to enable pre-rasterization if the {@link * WebView} is off screen to avoid flickering. See {@link WebSettings#setOffscreenPreRaster} for - * more details and do consider its caveats.
+ * more details and do consider its caveats. * * @param requestId An id that will be returned in the callback to allow callers to match * requests with callbacks. @@ -1990,7 +1985,7 @@ public class WebView extends AbsoluteLayout * here * * - *The returned message channels are entangled and already in started state.
+ *The returned message channels are entangled and already in started state. * * @return the two message ports that form the message channel. */ -- cgit v1.2.3