大家好,
我寫了一支程式去紀錄定位座標,
因有考量到GPS無法定位問題,
因此我有使用GPS_Provider與Network_Provider.
程式如下:
Location location=null;
locationMgr = (LocationManager)
(ctx.getSystemService(Context.LOCATION_SERVICE));
isGPSEnabled = locationMgr.isProviderEnabled(LocationManager.GPS_PROVIDER);
isNetworkEnabled =
locationMgr.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (isGPSEnabled || isNetworkEnabled) {
//若GPS有效則以GPS優先
if (isGPSEnabled) {
if (location == null) {
locationMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER,..略);
if (locationMgr != null) {
location = locationMgr.getLastKnownLocation(LocationManager.
GPS_PROVIDER);
}
}
}
//若GPS無效,則以網路定位
if (isNetworkEnabled) {
if(location == null){
locationMgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,.略);
if (locationMgr != null) {
location = locationMgr.getLastKnownLocation(LocationManager.
NETWORK_PROVIDER);
}
}
}
}
但我在捷運隧道測試時我的程式卻定不到位,
但是Google Map若可以!!
請問有人知道原因嗎?
謝謝!