Android Studio WebView with Tutorial Examples - SetFlix - The Latest Online Tools
Responsive Ads Here

Post Top Ad

Your Ad Spot

Saturday, 10 July 2021

Android Studio WebView with Tutorial Examples

Android Studio WebView with Tutorial Examples


Following is the case of showing a static HTML content in WebView in android applications. 

Make another android application utilizing android studio and give names as WebView. In the event that in the event that you don't know about making an application in android studio check this article Android Hello World App. 

Now open an activity_main.xml file from /res/layout path and write the code like as shown below

 

activity_main.xml

Whenever we are finished with adding a WebView to the format, presently we will show the static HTML content in WebView, for that

open main activity file MainActivity.java from \java\com.tutlane.webview path and write the code like as shown below.

 

MainActivity.java

 

In the event that you see above code, we are calling our design utilizing setContentView technique as R.layout.layout_file_name. Here our xml record name is activity_main.xml so we utilized document name activity_main and attempting to show the static HTML content in WebView.

By and large, in android WebView will go about as an implanted program to show the static or distant site page content in our android applications.

Presently we will perceive how to stack far off URL content in WebView with model in the android application.

By utilizing WebView LoadURL property we can stack far off URL content in our android applications. To show the distant URL content in webview change MainActivity.java document code as displayed underneath.

ManiActivity.java

 

In the event that you see above model, we are attempting to stack the distant URL (https://google.com) content in our android application utilizing WebView and we set a property setJavaScriptEnabled() to empower JavaScript on the grounds that of course the JavaScript is incapacitated in WebView. 

 

For the most part, the site page which we are stacking in WebView may utilize JavaScript. In the event that in the event that we will not empower the JavaScript, the usefulness which identified with JavaScript in website page will not work that is the explanation we are empowering the JavaScript utilizing setJavaScriptEnabled() To stack the far off web URL content, our application should have an admittance to the web. We need to set web access consents like as displayed beneath.

Manifest

 

Now open our application AndroidManifest.xml file in /manifests directory and write the code like as shown below

AndroidManifest.xml

 

Android studio WebView Example ... Android WebView is used to display web page in android. The web page can be loaded from same application or URL. It is used to Apps

1 comment:

Post Top Ad

Your Ad Spot