Android 谷歌地图API v2-仅通过GPS跟踪

Android 谷歌地图API v2-仅通过GPS跟踪,android,gps,google-maps-api-2,Android,Gps,Google Maps Api 2,我想解决这个问题,但我不知道如何解决。我只需要通过GPS跟踪我的应用程序的位置,不需要通过网络和互联网跟踪。现在,当我在外面的时候,我有一个错误的位置,带着很大的分歧来到我身边。需要以100米的精度定位 这是我的活动 public class MainActivity extends AppCompatActivity implements OnMapReadyCallback { private boolean aFoundMyLocation; private Document aDoc

我想解决这个问题,但我不知道如何解决。我只需要通过GPS跟踪我的应用程序的位置,不需要通过网络和互联网跟踪。现在,当我在外面的时候,我有一个错误的位置,带着很大的分歧来到我身边。需要以100米的精度定位

这是我的活动

public class MainActivity extends AppCompatActivity implements OnMapReadyCallback {

private boolean aFoundMyLocation;

private Document aDocument;
private GoogleMap aGoogleMap;
private GoogleDirection aGoogleDirection;

private LatLng aCurrentLocation;
...

@InjectView(R.id.txt_distance)
TextView txtDistance;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ButterKnife.inject(this);

    // initial map center settings
    aTargetLocation = new LatLng(49.199362, 18.737382);
    aGoogleDirection = new GoogleDirection(this);
    aFoundMyLocation = false;

    // inflate mapFragment
    SupportMapFragment mapFragment = (SupportMapFragment)
            getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}

...

@Override
public void onMapReady(GoogleMap googleMap) {
    aGoogleMap = googleMap;
    aGoogleMap.setBuildingsEnabled(true);
    aGoogleMap.setMyLocationEnabled(true);

    aGoogleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
        @Override
        public void onMyLocationChange(Location location) {
            aCurrentLocation = new LatLng(location.getLatitude(), location.getLongitude());
            ...
            }
        }
    });
}
}
还有我的部分舱单

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<application
...

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="..." />

</application>

有人能给我一个建议吗,如何编辑这个,只通过100米精度的GPS跟踪实际位置??感谢

请求LocationUpdate,最后一个参数上下文侦听器无法解析,您知道我必须更改什么吗?这是指应用程序的locationlistener。确保你有:导入android.location.LocationListenerok谢谢,导入错误,我的是来自google.android.gms.maps。。。我会去外面试试,你的MainActivity应该实现LocationListener,比如说公共类MainActivity扩展了FragmentActivity实现LocationListener
protected LocationManager locationManager;

//use this on your onCreate Method

locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);