Geolocation failed on Android webview and browser
I am facing a problem while working on Android Emulator. I am interested in setting the mock location through the LocationManager class and reading the geolocation in the Webview. I cannot read the location in the Webview where the location is read through the HTML5 geolocation A开发者_如何学运维PI. I have tried on different versions of Android emulator (for API level 8, 12). I looked into previous questions at stackoverflow, but no luck. Let me know if I am missing anything.
I noticed the following issues in my implementation:
- (In the logcat) WebChromeCliet was notified that the geolocation service failed to start.
- I tried to set mock location through geo fix telnet command. I did not notice any corresponding information in the logcat messages.
Similar problem I noticed in the Android Browser. The browser also did not detect the location after geo fix command.
FYI, in my code, 1. The project settings include ACCESS_MOCK_LOCATION, ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION
- The emulator has the settings for "mock locations" and "GPS support". I also enable geolocation and gps provider.
I will appreciate any help or suggestions.
In order to use html5 geolocation you have to use uses-permission android.permission.ACCESS_FINE_LOCATION. The html5 geolocation does not work when just coarse location is requested.
Alternatively, it might or might be possible to use uses-feature android.hardware.location.gps for an optional use, even though I haven't managed to have the html5 geolocation working with uses-feature (is it a limitation of the Android SDK?).
精彩评论