0
我想做一个简单的android应用程序来确定当前位置的GPS,但是当我在我的手机上运行应用程序它只是给我的准确性,而没有给出真正的坐标这里是我的代码位置管理器不工作
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
v1 = (TextView) findViewById(R.id.textView1);
v2 = (TextView) findViewById(R.id.textView1);
v3 = (TextView) findViewById(R.id.textView1);
int GpsUpdateInterval = 60 * 1000;
int GpsUpdateRadius = 15;
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
GpsUpdateInterval, GpsUpdateRadius, new LocationListener() {
@Override
public void onStatusChanged(String provider, int status,
Bundle exras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onLocationChanged(Location location) {
// this function trigger when a new location founded
v1.setText("Lat "
+ String.valueOf(location.getLatitude()));
v2.setText("Lng "
+ String.valueOf(location.getLongitude()));
v3.setText("Accurcy "
+ String.valueOf(location.getAccuracy()));
}
});
}
啊哈谢谢你,但你可以请检查代码的其余部分,如果它的正确与否 – Suhaybovic 2015-02-10 14:22:49
是的,是完全没有 – webo80 2015-02-10 14:24:34
非常感谢你 – Suhaybovic 2015-02-10 14:26:38