Reputation: 67
I am trying to make a simple android application to determine the current location by the GPS but when i run the app on my phone it just gives me the accuracy without giving the real coordinates Here's My Code
@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()));
}
});
}
Upvotes: 0
Views: 38
Reputation: 3403
v1 = (TextView) findViewById(R.id.textView1);
v2 = (TextView) findViewById(R.id.textView1);
v3 = (TextView) findViewById(R.id.textView1);
You have bad view bindings ;)
Upvotes: 1