【发布时间】:2015-05-22 15:56:49
【问题描述】:
我想解决问题,但我不知道如何解决。我只需要通过 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>
有人可以给我一个建议,如何编辑它以仅通过 GPS 以 100 米的精度跟踪实际位置?谢谢
【问题讨论】:
标签: android gps google-maps-api-2