Hi,
I want to call Geolocator.detect method many times. But I can’t.
I create an instance of a thread for call it in every 5000 miliseconds( Thread.sleep(5000) ). But the detect method doesn’t step into onSuccess or onFailure methods.
Here is the code below.
import com.vaadin.addon.touchkit.extensions.Geolocator;
import com.vaadin.addon.touchkit.extensions.PositionCallback;
import com.vaadin.addon.touchkit.gwt.client.vcom.Position;
import com.vaadin.addon.touchkit.ui.NavigationView;
import com.vaadin.ui.UI;
public class Locator extends NavigationView {
private static final long serialVersionUID = -4674692947624699697L;
private Worker worker;
public Locator() {
setCaption("Locator");
worker = new Worker();
worker.start();
}
public class Worker extends Thread{
private void sleep(){
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
}
private void callPosition()
{
Geolocator.detect(new PositionCallback() {
@Override
public void onSuccess(Position position) {
System.out.println(position);
}
@Override
public void onFailure(int errorCode) {
System.out.println(errorCode);
}
});
}
@Override
public void run() {
synchronized (UI.getCurrent()) {
while (true) {
sleep();
callPosition();
}
}
}
}
}
Thanks for replies.