36 lines
1.0 KiB
Kotlin
36 lines
1.0 KiB
Kotlin
package me.rxresu.app
|
|
|
|
import android.annotation.SuppressLint
|
|
import android.os.Bundle
|
|
import android.webkit.WebView
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
|
class MainActivity : AppCompatActivity() {
|
|
|
|
private lateinit var webView: WebView
|
|
|
|
private var url = "https://rxresu.me"
|
|
|
|
@SuppressLint("SetJavaScriptEnabled")
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
setContentView(R.layout.activity_main)
|
|
|
|
webView = findViewById(R.id.webview)
|
|
|
|
webView.webViewClient = CustomWebViewClient()
|
|
webView.settings.javaScriptEnabled = true
|
|
webView.settings.userAgentString = "Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Mobile Safari/537.36"
|
|
|
|
webView.loadUrl(url)
|
|
}
|
|
|
|
override fun onBackPressed() {
|
|
if (webView.canGoBack()) {
|
|
webView.goBack()
|
|
} else {
|
|
super.onBackPressed()
|
|
}
|
|
}
|
|
}
|