install android studio

WebView in Android Studio

WebView:

Web view is the view available in Android Studio for use in Android apps.It acts like a browser on which you can pass the url and get the result page within the app.

Implementation :

To implement webview in Android Studio .Put the code in WebActivity.java

public class Webview extends AppCompatActivity {
Button btnBack;
WebView webView;
private class MyWebViewClient extends WebViewClient {
private MyWebViewClient() {
}
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
this.webView = (WebView) findViewById(R.id.webview);
this.webView.setWebViewClient(new MyWebViewClient());
openURL();
}
private void openURL() {
this.webView.loadUrl("http://www.internationalgitamahotsav2016.com/");
this.webView.requestFocus();
}
}

Problem will be discussed in Comment section.

About the author

Generic Bytes

Hi! we are from Generic Bytes an aspiring bloggers with an obsession of things tech.This blog is dedicated to people who want to learn the technology.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *