Cannot resolve setWebChromeClient method (anonymous android

I am trying to learn building applications for Android, and the first project is to browse a website that I created that uses GPS localization. But when I try to use webView.setWebChromeClient(... , I get the following error message: Cannot resolve method 'setWebChromeClient(anonymous android.webkit.WebChromeClient) .

If this helps, I added the necessary permissions to my AndroidManifest.xml:

 <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_GPS" /> <uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" /> <uses-permission android:name="android.permission.ACCESS_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

How can i fix this?

enter image description here

-2
source share
1 answer

Delete the incorrect static import on line 13 and move the call to line 31 after assigning the view to a local variable:

 WebView view = findViewById(R.id.webView) view.setWebChromeClient(...) 
+1
source

Source: https://habr.com/ru/post/1275854/


All Articles