1
我得到的android手機的位置爲:爲什麼當我更改位置時,android手機的當前位置不會改變?
android.location.Location locationA;
LocationManager locationManager;
Criteria cri = new Criteria();
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
String tower = locationManager.getBestProvider(cri, false);
locationA = locationManager.getLastKnownLocation(tower);
if (locationA != null) {
// lat = (double) (locationA.getLatitude() * 1E6);
// longi = (double) (locationA.getLongitude() * 1E6);
double lat = locationA.getLatitude();
double longi = locationA.getLongitude();
TextView txt = (TextView) findViewById(R.id.textView1);
String td = String.valueOf(lat) + "," + String.valueOf(longi);
txt.setText(td);
}
爲什麼android手機的當前位置,當我改變位置,並再次獲得當前位置不改?
那麼你正在使用哪個提供者? GPS或網絡? – Andromeda
GPS和網絡(String tower = locationManager.getBestProvider(cri,false); ) – mum