WebView地理位置仅适用于Wifi启用/始终扫描

时间:2018-12-13 07:30:15

标签: android android-webview android-location google-geolocation

我正在尝试使WebView能够获取移动数据(3g / lte)的位置,但是只有在使用WiFi /启用wifi扫描时才能接收该位置。

以下是使用移动数据时系统打印的位置请求的日志:


LocationManagerService: requestLocationUpdates: uid=11294, pid=17340, provider=fused, package=com.my.package listener= android.location.ILocationListener$Stub$Proxy@713f86 intent= null

由于某种原因,从未收到该位置,WebView仍在寻找位置状态。

如果打开或启用了Wifi扫描功能,即使它处于关闭状态,它在wifi或移动数据上的运行速度都非常快


LocationManagerService: requestLocationUpdates: uid=10014, pid=3464, provider=gps, package=com.google.android.gms listener= android.location.ILocationListener$Stub$Proxy@6f09c54 intent= null

仅在请求GPS提供程序的情况下,单独进行融合是行不通的。


Relevant granted permissions:
uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"

我的网络视图设置:


mWebView.settings.domStorageEnabled = true
mWebView.settings.builtInZoomControls = true
mWebView.settings.loadWithOverviewMode = true
mWebView.settings.useWideViewPort = true
mWebView.settings.displayZoomControls = false
mWebView.settings.mediaPlaybackRequiresUserGesture = false
mWebView.settings.setAppCacheEnabled(true)
mWebView.settings.databaseEnabled = true
mWebView.settings.domStorageEnabled = true
mWebView.settings.javaScriptEnabled = true
mWebView.settings.allowContentAccess = true
mWebView.settings.javaScriptCanOpenWindowsAutomatically = true
mWebView.settings.setGeolocationEnabled(true)
mWebView.settings.setGeolocationDatabasePath(context.filesDir.path)

ChromeClient:


mWebView.webChromeClient = object : WebChromeClient() {

            override fun onGeolocationPermissionsShowPrompt(origin: String?, callback: GeolocationPermissions.Callback) {
                super.onGeolocationPermissionsShowPrompt(origin, callback)

                OLog.i(tag(), "Requesting location")
                callback.invoke(origin, true, true)
            }
        }
    

0 个答案:

没有答案