I have to call a webserbice in every 10 seconds for this I am using Timer. But I am getting Exception like Can't create handler inside thread that has not called Looper.prepare().
my code for calling ws:
Timer timer = new Timer();
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
callGetConnectedUserWS("Please wait...");
}
};
timer.schedule(timerTask, 0, 10000);
public void callGetConnectedUserWS(String msg, int getConnectedUsersPID) {
if (NetworkAvailablity.getInstance().checkNetworkStatus(FriendActivity.this)) {
WebServiceCommunicator.getInstance().registerForServerResponse(FriendActivity.this);
ServerRequestParams serverRequestParams = null;
HashMap<String, String> properties = new HashMap<String, String>();
properties.put("username", _myUserName);
serverRequestParams = new ServerRequestParams(getParent(), properties, WebServiceDetails.METHOD_NAME_GET_CONNECTED_USERS, WebServiceDetails.URL_WS_USER, msg);
WebServiceCommunicator.getInstance().callWebService(FriendActivity.this, serverRequestParams, getConnectedUsersPID);
} else {
Constant.ShowAlertDialog("",Constant.MSG_INTERNETERROR, getParent(), false);
}
}