I’ve looked at a few other questions and tutorials but I’m not getting what I’m looking for
I am trying to get the latitude and longitude in this format
latitude = 40.769134 , longitude = -73.960905
I implemented this class which takes my global variables latitude and longitude (they are long data types)
class GpsListener implements LocationListener{
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
latitude = location.getLatitude();
longitude = location.getLongitude();
//float speed = location.getSpeed();
checkin();
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
// TODO Auto-generated method stub
}
}
I’ve looked at other tutorials here and notice that people use the LocationManager class to interface with my LocationListener but all I really need to do is use a Location object becuase my class GpsListener.onLocationChanged(.. ) needs a location object, but can you give an example or guidance on how to use the location object or how to simply get this longitude and latitude?
I am simply passing the latitude and longitude to a server so I dont need to do anything else with the GPS module, my checkin() function makes the server call
are you trying to avoid using the LocaitonManager?
if you just want to use it once, I suppose you could deregister everything after receiving a location. But maybe you want to make sure the accuracy is within x meters etc..