我在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()");如何被调用...
我做错了什么?
在此之前,非常感谢,
发布于 2013-09-26 13:03:59
我发现AsyncHttpClient的当前实现-我开始使用的第一个版本- 1.4.3 (2013-09-25)在本地内部网主机名方面存在一些问题。我使用本地网络进行测试,was服务器在我的计算机上运行,它正在调用onStart,但从未调用onSuccess或任何其他方法。
我的主机名是RM_UB02 (不带Internet域后缀)。安卓和Chrome浏览器能够解析网址(rmub02/test/page.html),但AsyncHttpClient无法工作。
我更改为本地intranet IP地址(192.168.1.104),它开始工作。我发现它适用于互联网名称(http://slashdot.org ),但不适用于本地网络。
发布于 2013-05-18 22:57:46
@Override
public void onStart()
{
}
@Override
public void onFinish()
{
}
@Override
public void onSuccess()
{
}
@Override
public void onFailure()
{
}https://stackoverflow.com/questions/11260754
复制相似问题