-2

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

If it will help anything, I have added the needed permissions in 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

Airikr
  • 6,258
  • 15
  • 59
  • 110

1 Answers1

1

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

WebView view = findViewById(R.id.webView)
view.setWebChromeClient(...)
makovkastar
  • 5,000
  • 2
  • 30
  • 50
  • Thank you. But then it complains about the line I removed that was on line 13. http://i.imgur.com/rzzFkXP.jpg – Airikr May 01 '17 at 21:01
  • Type the full view id: findViewById(R.id.webView) instead of findViewById(webView). – makovkastar May 01 '17 at 21:03
  • Thanks. But now it complains on `view` in `view.setWebChromeClient(...`. The same error message for `origin` and `callback`. And for the `GeolocationPermissions.Callback`, I get an error message that says `Expression expected`. http://i.imgur.com/HGrPfsl.jpg – Airikr May 01 '17 at 21:16
  • 1
    Try to move your code inside the 'onCreate' method. Currently it's outside the closing bracket. – makovkastar May 01 '17 at 21:18
  • Thanks. That solved it! Now I just have to figure out how to make the application can handle the GPS localization. – Airikr May 01 '17 at 21:22