Lines Matching full:webview
1 page.title=Building Web Apps in WebView
8 <li>Use {@link android.webkit.WebView} to display web pages in your Android application
15 <li><a href="#AddingWebView">Adding a WebView to Your Application</a></li>
16 <li><a href="#UsingJavaScript">Using JavaScript in WebView</a>
31 <li>{@link android.webkit.WebView}</li>
40 you can do it using {@link android.webkit.WebView}. The {@link android.webkit.WebView} class is an
43 browser, such as navigation controls or an address bar. All that {@link android.webkit.WebView}
46 <p>A common scenario in which using {@link android.webkit.WebView} is helpful is when you want to
49 that contains a {@link android.webkit.WebView}, then use that to display your document that's
52 <p>Another scenario in which {@link android.webkit.WebView} can help is if your application provides
55 find that it's easier to build a {@link android.webkit.WebView} in your Android application that
59 and then implement a {@link android.webkit.WebView} in your Android application that loads the web
62 <p>This document shows you how to get started with {@link android.webkit.WebView} and how to do some
68 <h2 id="AddingWebView">Adding a WebView to Your Application</h2>
70 <p>To add a {@link android.webkit.WebView} to your Application, simply include the {@code
71 <WebView>} element in your activity layout. For example, here's a layout file in which the
72 {@link android.webkit.WebView} fills the screen:</p>
76 <WebView xmlns:android="http://schemas.android.com/apk/res/android"
77 android:id="@+id/webview"
83 <p>To load a web page in the {@link android.webkit.WebView}, use {@link
84 android.webkit.WebView#loadUrl(String) loadUrl()}. For example:</p>
87 WebView myWebView = (WebView) findViewById(R.id.webview);
102 <p>That's all you need for a basic {@link android.webkit.WebView} that displays a web page.</p>
107 <h2 id="UsingJavaScript">Using JavaScript in WebView</h2>
109 <p>If the web page you plan to load in your {@link android.webkit.WebView} use JavaScript, you
110 must enable JavaScript for your {@link android.webkit.WebView}. Once JavaScript is enabled, you can
116 <p>JavaScript is disabled in a {@link android.webkit.WebView} by default. You can enable it
118 android.webkit.WebSettings} attached to your {@link android.webkit.WebView}. You can retrieve {@link
119 android.webkit.WebSettings} with {@link android.webkit.WebView#getSettings()}, then enable
126 WebView myWebView = (WebView) findViewById(R.id.webview);
133 that's designed specifically for the {@link android.webkit.WebView} in your Android application,
143 android.webkit.WebView} in your Android
149 android.webkit.WebView#addJavascriptInterface(Object,String) addJavascriptInterface()}, passing it
183 <p>You can bind this class to the JavaScript that runs in your {@link android.webkit.WebView} with
184 {@link android.webkit.WebView#addJavascriptInterface(Object,String) addJavascriptInterface()} and
188 WebView webView = (WebView) findViewById(R.id.webview);
189 webView.addJavascriptInterface(new WebAppInterface(this), "Android");
193 android.webkit.WebView}. At this point, your web application has access to the {@code
208 android.webkit.WebView} automatically makes it
217 android.webkit.WebView#addJavascriptInterface(Object,String) addJavascriptInterface()} allows
219 security issue. When the HTML in the {@link android.webkit.WebView} is untrustworthy (for example,
223 {@link android.webkit.WebView#addJavascriptInterface(Object,String) addJavascriptInterface()} unless
224 you wrote all of the HTML and JavaScript that appears in your {@link android.webkit.WebView}. You
226 navigate to other web pages that are not your own, within your {@link android.webkit.WebView}
237 <p>When the user clicks a link from a web page in your {@link android.webkit.WebView}, the default
241 android.webkit.WebView},
242 so links open within your {@link android.webkit.WebView}. You can then allow the user to navigate
244 android.webkit.WebView}.</p>
247 android.webkit.WebViewClient} for your {@link android.webkit.WebView}, using {@link
248 android.webkit.WebView#setWebViewClient(WebViewClient) setWebViewClient()}. For example:</p>
251 WebView myWebView = (WebView) findViewById(R.id.webview);
252 myWebView.{@link android.webkit.WebView#setWebViewClient(WebViewClient) setWebViewClient}(new WebViewClient());
255 <p>That's it. Now all links the user clicks load in your {@link android.webkit.WebView}.</p>
259 android.webkit.WebViewClient#shouldOverrideUrlLoading(WebView,String)
265 public boolean {@link android.webkit.WebViewClient#shouldOverrideUrlLoading(WebView,String) shouldOverrideUrlLoading}(WebView view, String url) {
267 // This is my web site, so do not override; let my WebView load the page
279 android.webkit.WebView}:</p>
282 WebView myWebView = (WebView) findViewById(R.id.webview);
283 myWebView.{@link android.webkit.WebView#setWebViewClient(WebViewClient) setWebViewClient}(new MyWebViewClient());
287 {@link android.webkit.WebViewClient#shouldOverrideUrlLoading(WebView,String)
290 loading (it allows the {@link android.webkit.WebView} to load the URL as usual). If the URL host
300 <p>When your {@link android.webkit.WebView} overrides URL loading, it automatically accumulates a
303 android.webkit.WebView#goBack()} and {@link android.webkit.WebView#goForward()}.</p>
312 if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.{@link android.webkit.WebView#canGoBack() canGoBack}()) {
313 myWebView.{@link android.webkit.WebView#goBack() goBack}();
322 <p>The {@link android.webkit.WebView#canGoBack()} method returns
324 android.webkit.WebView#canGoForward()} to check whether there is a forward history. If you don't
326 android.webkit.WebView#goBack()} or {@link android.webkit.WebView#goForward()} does nothing.</p>