ac4android
Well-Known Member
My handler has an inner class that calls the requestLocationUpdates() method.
It has the following syntax error:
"Cannot resolve method requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,this);
But it recognises both the getLastKnownLocatoin() method and my locationmanager !?!
Where have I gone wrong and how do I fix it?
The flow of logic is quite bad at the moment, but I just want to get it working first.
It has the following syntax error:
"Cannot resolve method requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,this);
But it recognises both the getLastKnownLocatoin() method and my locationmanager !?!
Where have I gone wrong and how do I fix it?
The flow of logic is quite bad at the moment, but I just want to get it working first.
Code:
private void runLocTimer() {
final TextView sysmsgview = (TextView) findViewById(R.id.sysmsg_view);
final TextView latitudeview = (TextView) findViewById(R.id.latitude_view);
final TextView longitudeview = (TextView) findViewById(R.id.longitude_view);
final TextView accuracyview = (TextView) findViewById(R.id.accuracy_view);
locationmanager = (LocationManager) context.getSystemService(LOCATION_SERVICE);
// get GPS status
gpsEnabled = locationmanager.isProviderEnabled(LocationManager.GPS_PROVIDER);
// get network statuis
networkEnabled = locationmanager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
//
final Handler handler = new Handler();
handler.post(new Runnable() {
@Override
public void run() {
//TODO
String slat = String.valueOf(dd);
sysmsgview.setText(slat);
latitudeview.setText(latitude);
longitudeview.setText(longitude);
accuracyview.setText(accuracy);
if(running){
dd++;
if (gpsEnabled){
if (location == null) {
locationmanager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
if (locationmanager != null) {
location = locationmanager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
latitude = String.valueOf(location.getLatitude());
longitude = String.valueOf(location.getLongitude());
accuracy = String.valueOf(location.getAccuracy());
}
}
}
}
}
handler.postDelayed(this, 1000);
}
});
}