Skip to content

@charlieCollins /WebViewTest
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
WebView test/example for 4.2.1.
package com.totsp.webviewtest;
import android.app.Activity;
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;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webview = (WebView) findViewById(R.id.webview);
loadWebview();
}
private void loadWebview() {
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
Log.d(TAG, "onPageFinished url:" + url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.d(TAG, "shouldOverrideUrlLoading");
return false;
}
@Override
public void onPageStarted(WebView view, String url, android.graphics.Bitmap favicon) {
Log.d(TAG, "onPageStarted url:" + url);
}
@Override
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...");
webview.loadUrl("http://www.google.com");
}
}
@charlieCollins

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.