我在 onCreate() 中有以下计时器:
new Timer().scheduleAtFixedRate(new TimerTask(){
public void run() {
Log.i("EOH","timer");
updateMarkers();
}}, 0, 1000);
如您所见,它每秒调用一次函数 updateMarkers()。
这是 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() {
}
});
}
我遇到的问题是Log.i("EOH","onStart()");
永远不会被调用!然而Log.i("EOH","updateMarkers()");
被调用...
我究竟做错了什么?
提前谢谢了,