при попытке загрузить веб сайт в WebView пишет ERR_CASHE_MISS
Ответы (1 шт):
Автор решения: Юрий GeneralAnabolik
→ Ссылка
Заработало когда вот так написал:
package com.example.spektr
import android.os.Bundle
import android.webkit.WebResourceRequest
import android.webkit.WebSettings
import android.webkit.WebView
import com.google.android.material.bottomnavigation.BottomNavigationView
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import com.example.spektr.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
// private ActivityMainBinding binding;
//val URL: String
private lateinit var binding: ActivityMainBinding
// var URL = "https://spektr-ekb.ru";
// val myWebView: WebView = findViewById(R.id.WebView)
// myWebView.loadUrl("http://www.example.com")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// val myWebView = WebView(R.id.WebView)
// setContentView(myWebView)
// myWebView.loadUrl("https://www.ya.ru")
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
//View view
// val navView: BottomNavigationView = binding.navView
/*
val navController = findNavController(R.id.nav_host_fragment_activity_main)
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
val appBarConfiguration = AppBarConfiguration(
setOf(
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications
)
)
setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)
*/
val myWebView: WebView = binding.WebView
myWebView.loadUrl("https://spektr-ekb.ru")
}
}