Webview in Android

Hello,

Today we are going to learn about webview in android. so webview is versy use full when you want to load any URL in our android app. Let's take an example.
Into this we are going to learn abou activiy as a webview and url open in full screen view in android.


MainActivity.java


public class MainActivity extends AppCompatActivity {
    private WebView wv1;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        wv1  = new WebView(this);
        wv1.getSettings().setJavaScriptEnabled(true);
        wv1.setWebViewClient(new WebViewClient() {
            @SuppressWarnings("deprecation")
            @Override             
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            }
            @TargetApi(android.os.Build.VERSION_CODES.M)
            @Override             
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());
            }
        });
        wv1.loadUrl("https://www.google.com/");
        setContentView(wv1 );
    }
}

Into this android demo we don't need to use XML file becouce we are going to use activity as a android webview.

OUTPUT:



Comments

  1. RSI Casino - DrmCD
    Information and images about RSI Casino, including games, 의정부 출장마사지 payment methods, RSI casino. 태백 출장안마 Deposit using 오산 출장샵 credit cards. Payment. Deposit  전라북도 출장안마 Rating: 2.5 천안 출장마사지 · ‎1 review

    ReplyDelete

Post a Comment