onLocationChanged
method works like other Listener like onClickListener
. When your location change this listener will call and it's like user click a button. So no need to use Thread but if you want save th Locations data or something else it will be important to use Thread.
This is my example that use locationListener with thread ,but Thread used only for send data nothing else:
public void onLocationChanged(final Location location) {
// TODO Auto-generated method stub
locationThread = new Thread(new Runnable() {
public void run() {
// TODO Auto-generated method stub
int Status = 0;
latitudeField=location.getLatitude();
longitudeField=location.getLongitude();
Date dt = new Date();
dt.setDate(dt.getDate());
Status=CallSoap.CurrentPosition(YarVisitLogin.UserName, YarVisitLogin.Password, YarVisitLogin.Visitor, latitudeField, longitudeField, PersianCalendar.getPersianDate(dt), PersianCalendar.getPersianTime());
yardb.InsertIntoMyLocations(yardb.getMaxMyLocation_ID()+1, PersianCalendar.getPersianDate(dt), PersianCalendar.getPersianTime(), Double.toString(latitudeField), Double.toString(longitudeField), Status);
}
});
locationThread.start();
}