我尝试了hablitar的GPS定位功能,将其放入清单android:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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" />
并将webview设置为:
setGeolocationEnabled(true);
但仍无效。我该怎么做才能让它发挥作用?我是新来的。
答案 0 :(得分:2)
您需要开始在代码中请求GPS更新。
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
// Called when a new location is found by the location provider.
}
}
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1000, locationListener);
然后,您可以获取您收到的GPS值,并通过网址
将其传递给网页浏览