I have the following timer in onCreate():
new Timer().scheduleAtFixedRate(new TimerTask(){
public void run() {
Log.i("EOH","timer");
updateMarkers();
}}, 0, 1000);
As you can see, it calls the function updateMarkers() every second.
Here is updateMarkers():
private void updateMarkers(){
Log.i("EOH","updateMarkers()");
Drawable drawable = this.getResources().getDrawable(R.drawable.google_maps_marker);
final MyItemizedOverlay itemizedoverlay = new MyItemizedOverlay(drawable,mapView);
AsyncHttpClient myClient = new AsyncHttpClient();
final PersistentCookieStore myCookieStore = new PersistentCookieStore(context);
myClient.setCookieStore(myCookieStore);
RequestParams params = new RequestParams();
params.put("sw_lat", String.valueOf(centrePoint.getLat()-(Double.valueOf(mapView.getLatitudeSpan())/2.0)));
params.put("sw_lng", String.valueOf(centrePoint.getLat()-(Double.valueOf(mapView.getLongitudeSpan())/2.0)));
params.put("ne_lat", String.valueOf(centrePoint.getLat()+(Double.valueOf(mapView.getLatitudeSpan())/2.0)));
params.put("ne_lng", String.valueOf(centrePoint.getLat()+(Double.valueOf(mapView.getLongitudeSpan())/2.0)));
myClient.post("http://www.prestocab.com/ajax/getRanks.php", params, new AsyncHttpResponseHandler() {
public void onStart() {
thinger.setVisibility(View.VISIBLE);
Log.i("EOH","onStart()");
}
public void onSuccess(String response) {
Log.i("EOH","xxx: "+response);
thinger.setVisibility(View.INVISIBLE);
try{
JSONArray arr=(JSONArray) new JSONTokener(response).nextValue();
Log.i("EOH","yyy: "+String.valueOf(arr.length()));
}catch(JSONException e){
}
}
public void onFailure(Throwable e) {
thinger.setVisibility(View.INVISIBLE);
}
public void onFinish() {
}
});
}
The problem I'm having is that Log.i("EOH","onStart()");
never gets called! However Log.i("EOH","updateMarkers()");
gets called...
What am I doing wrong?
Many thanks in advance,
I found out that current implementation of AsyncHttpClient - the first I start using - version 1.4.3 (2013-09-25) has some problem with local intranet hostnames. I was testing using a local network with the webserver running on my computer and it was calling onStart, but never calling onSuccess or any other methods.
My hostname was RM_UB02 (without the Internet domain suffixes). Android and Chrome web browsers were able to resolve the URL (http:// RM_UB02/test/page.html), but AsyncHttpClient never worked.
I changed to the local intranet IP address (192.168.1.104) and it started working. I figured out that it was working all right for Internet names ( http://slashdot.org ), but not for local networks.
@Override
public void onStart()
{
}
@Override
public void onFinish()
{
}
@Override
public void onSuccess()
{
}
@Override
public void onFailure()
{
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.