xxxxxxxxxx
lateinit var web: WebView
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
web = findViewById<WebView>(R.id.web)
web.webViewClient = WebViewClient()
web.loadUrl("https://v2.crichd.tv/new-home")
val webs = web.settings
webs.javaScriptEnabled = true
}
override fun onBackPressed() {
if (web.canGoBack()) {
web.goBack()
} else {
super.onBackPressed()
}
}
xxxxxxxxxx
private WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webview);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("https://www.javatpoint.com/java-tutorial");
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
}
@Override
public void onBackPressed() {
if (webView.canGoBack()) {
webView.goBack();
} else {
super.onBackPressed();
}
}