Q:

Can't create handler…Looper.prepare()

I am writing a client server program, which client gives its location to the server, and server shows it.  
I have a class to get the location latitude and longitude. 
I have a timer to retrieve location every 2 seconds.  But I get this error:
Can't create handler inside thread that has not called Looper.prepare()
Here is my timer inside onCreate method:
time.scheduleAtFixedRate(new TimerTask() {

@Override
public void run() {

GetLocation();

}
}, 0, sampling_interval);
}

And here is the GetLocation method:
private void GetLocation(){

    gps = new GPSTracker(MainActivity.this);    
    // check if GPS enabled
    if(gps.canGetLocation()){

        double latitude = gps.getLatitude();
        double longitude = gps.getLongitude();

        Log.d("Latitude", Double.toString(latitude));

    }else{

        gps.showSettingsAlert();
    }
} 

The problem is:
    gps = new GPSTracker(MainActivity.this);
if I put this line inside the MainActivity there is no problem, but the problem is that I dont get updated location, I just get same location because its created only for one time.  So this line should be inside GetLocation() method, which I can get updated location every time the timer calls it. 
Any help? 

A:

This is an Android motto: avoid Timer/TimerTask use Handler instead.