Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
WebView test/example for 4.2.1.
package com.totsp.webviewtest;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
private static final String TAG = "WebViewTest";
private WebView webview;
protected void onCreate(Bundle savedInstanceState) {
webview = (WebView) findViewById(;
private void loadWebview() {
webview.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
Log.d(TAG, "onPageFinished url:" + url);
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.d(TAG, "shouldOverrideUrlLoading");
return false;
public void onPageStarted(WebView view, String url, favicon) {
Log.d(TAG, "onPageStarted url:" + url);
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Log.d(TAG, "onRecievedError code:" + errorCode + " desc:" + description + " failingUrl:" + failingUrl);
Log.d(TAG, "******************* LOAD URL...");

charlieCollins commented Jan 30, 2013

Logging works as expected, and WebView loads the URL as expected.

D/WebViewTest( 3502): onPageStarted url:
I/ActivityManager( 583): Displayed com.totsp.webviewtest/.MainActivity: +466ms
D/WebViewTest( 3502): onPageFinished url:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment