1.Basic
LocationManager lm = (LocationManager) getSystemService (LOCATION_SERVICE);
String p = lm.getBestProvider (new Criteria () and true);
lm.requestLocationUpdates (p, 10000 and 0, this);
Location location = lm.getLastKnownLocation (p);
Acquiring in every 10 seconds, because it is position interval zero, when we want being spot with the position, you use zero.
Expedient of position specification
As for Android 2 systems having as an expedient of position specification, the [zatsukuri] position which used the information of telecommunication network and the accurate version which used the radio wave of GPS and there is two. Perhaps manifest
<uses-permission android: name= " android.permission.ACCESS_COARSE_LOCATION "/>
<uses-permission android: name= " android.permission.ACCESS_FINE_LOCATION "/>
It is thought that it is corresponding.
As for network edition position specification being quick, the response is good, but rather about 100m being unconcerned with [zatsukuri], it slips. The version of GPS specifies accurately in the error about of 15m, but because time is required to for circumstance plug specification very, it does not face to the application which is moved ill-smelling when and, it enters into the shadow of the thing, becoming unable to use directly, also stability is low.
As the name of Provider
LocationManager.GPS_PROVIDER
With
LocationManager.NETWORK_PROVIDER
Is given
GPS_PROVIDER