开发者

Geolocation in webview error

On an Android 2.2 emulator, loading a blank page with the following script fails:

navigator.geolocation.getCurrentPosition(
          function(pos){
            var lat = pos.coords.latitude;
            var lon= pos.coords.longitude;
            alert('success ' + lat + ',' + lon);
          },
          function(开发者_高级运维){
              alert('geoloc test FAILED');
          }
        );

Specifically, it causes the error:

I/Database(  306): sqlite returned: error code = 14, msg = cannot open file at source line 25467

I've added pretty much every geo-related permission I can find to the manifest:

<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" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />

I'm not sure what else I can do! I've been at this for hours with no progress - any insight would be greatly appreciated.

(I am able to view my location in the emulator browser after sending geo fix)


According to the phonegap mailing list, this error is normal and can be safely ignored. All Android devices 2.X onwards have geolocation built into the browser.

A possibly helpful note: when testing geolocation, it helped me a lot to use DDMS to set a fake location, or simply telnet to localhost:5554 and run the command geo fix 50.0 50.0, for example, to set mock gps lat/long coords to (50, 50).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜