標籤:android io ar 使用 sp 資料 on art 問題
============問題描述============
各位大神:
如何將GPS,基站定位,WiFi定位有效整合到一起,讓系統根據網路化境做出有效定位方式,謝謝啦
============解決方案1============
樓上說的對,實現locationlistener的onLocationChanged,onProviderDisabled,onProviderEnabled,onStatusChanged介面。
============解決方案2============
但是基站定位和wifi定位(IP)還是需要第三方包依賴的啊,否則你就得自己搭建基站資料庫,拿到所有基站的資料,ip也是一樣,才能進行解析。
============解決方案3============
如此 你就註冊了兩個 provider , GPS_PROVIDER & NETWORK_PROVIDER。 但是還是有問題 gps 精度高 可靠, 但是穩定性差 , network方式 速度快 但是不可靠 ,因為位置取決於你使用的代理等原因。至於你的初衷“系統根據網路化境做出有效定位方式” ,這個可以做一個互動選擇讓使用者自行選定 如果gps獲得不了位置 使用網路位置,如果兩種方式都有位置資訊,且誤差超過一定程度 ,讓使用者自行決定想使用哪個。
引用 9 樓 tomkan 的回複:
private android.location.LocationManager mLocationManager;
LocationListener [] mLocationListeners = new LocationListener[] {
new LocationListener(android.location.LocationManager.GPS_PROVIDER),
new LocationListener(android.location.LocationManager.NETWORK_PROVIDER)
};
if (mLocationManager == null) {
mLocationManager = (android.location.LocationManager)
mContext.getSystemService(Context.LOCATION_SERVICE);
}
if (mLocationManager != null) {
try {
mLocationManager.requestLocationUpdates(
android.location.LocationManager.NETWORK_PROVIDER,
1000,
0F,
mLocationListeners[1]);
} catch (SecurityException ex) {
Log.i(TAG, "fail to request location update, ignore", ex);
} catch (IllegalArgumentException ex) {
Log.d(TAG, "provider does not exist " + ex.getMessage());
}
try {
mLocationManager.requestLocationUpdates(
android.location.LocationManager.GPS_PROVIDER,
1000,
0F,
mLocationListeners[0]);
} catch (SecurityException ex) {
Log.i(TAG, "fail to request location update, ignore", ex);
} catch (IllegalArgumentException ex) {
Log.d(TAG, "provider does not exist " + ex.getMessage());
}
Log.d(TAG, "startReceivingLocationUpdates");
}
android定位問題