load URL By WebView - Android android.webkit

Android examples for android.webkit:WebView

Description

load URL By WebView

Demo Code

import android.app.AlertDialog;
import android.content.Context;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class Main{

    public static void loadByWebView(final Context context, String url) {
        WebView webView = new WebView(context);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.addJavascriptInterface(new Handler(context), "handler");
        webView.setWebViewClient(new WebViewClient() {
            @Override/*from   www. ja  v  a 2s.c  o m*/
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
            }
        });
        webView.loadUrl(url);
    }

}

Related Tutorials