-1
我要問,如果有另一種方式使用map.I只想要的位置,使一些查詢與它。是有采取用戶位置與出出位置任何更智能,更高效的方式來做到這一點,包括在android中的地圖活動?採取用戶(經緯度),使用地圖的Android
我要問,如果有另一種方式使用map.I只想要的位置,使一些查詢與它。是有采取用戶位置與出出位置任何更智能,更高效的方式來做到這一點,包括在android中的地圖活動?採取用戶(經緯度),使用地圖的Android
Android有兩種基本的方法來確定用戶的位置。首先是使用自Android首次推出以來可用的內置位置API。並有Google Play服務。
所以,當你不使用的地圖說:
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double longitude = location.getLongitude();
double latitude = location.getLatitude();
final LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
longitude = location.getLongitude();
latitude = location.getLatitude();
}
public void onProviderDisabled(String arg0) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String arg0) {
// TODO Auto-generated method stub
}
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
// TODO Auto-generated method stub
}
};
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 10, locationListener);
,如果你想使用GPS不要忘記權限:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
檢查這些文件,以更多: https://developer.android.com/guide/topics/location/strategies.html
這裏你去:https://developer.android.com/training/location/index.html – c0rtexx