While searching for an answer in google, it seems that I\'m not the only one stuck with a problem that seems impossible to solve.
I\'ve managed to create a WebView w
-> Hello Please Try This Code This Code Run Fine
-> For More Information of Documentation Please Visit https://developer.android.com/guide/webapps/webview#java
-> This Link Work Fine in Nov 2019 Currently I Don't Know
-> Your XML Code For Design is
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
-> And Your Java Code For Backend is
package com.developer.harshil.kaneria.webview;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl("https://github.com/Harshil-Kaneria");
}
}
-> Here in Java Code
WebSettings webSettings = myWebView.getSettings();
And This
webSettings.setJavaScriptEnabled(true);
-> It is Allow To JavaScript Run When Page is Load
-> Thanks A Lot For Read.
Similar to @mdelolmo answer, but in Kotlin:
webview.setWebChromeClient(WebChromeClient())
webview.setWebViewClient(WebViewClient())
webview.clearCache(true)
webview.clearHistory()
webview.getSettings().setJavaScriptEnabled(true)
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true)