写了一个按钮,按按钮后会进行一个异步处理,可是不知道为什么总也没法进入到异步去,不知道为什么连异步的onPreExecute()的进度对话框都没出现
btnLoca.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
btnLoca.setEnabled(false);
ProgressDialog pdloca=new ProgressDialog(MainActivity.this);
AsynLoca a = new AsynLoca(pdloca);
a.execute(task);
//与文件对比定位

//在地图上显示当前位置

//定位后激活导航按钮
btnNavi.setEnabled(true);
btnLoca.setEnabled(true);
//清空采集到的数据
clearData(router);
}
class AsynLoca extends AsyncTask<recordTask,Integer,Integer>{
ProgressDialog pdloca;
recordTask task;
Timer timer=new Timer();
final TextView show = (TextView)findViewById(R.id.textView1);
public AsynLoca(ProgressDialog pdloca){
this.pdloca=pdloca;
}
@Override
    protected void onPreExecute() {
pdloca.setTitle("Locating");
pdloca.setMessage("Locating now, please wait...");
pdloca.setIndeterminate(true);
pdloca.show();
    }
@Override
    protected Integer doInBackground(recordTask... t) {

task=t[0];
timer.schedule(task,1000,1000);
while(task.getTryTimes()<3){
//等待三次采集
publishProgress(task.getTryTimes());
}
timer.cancel();
return null;
    }
@Override
protected void onProgressUpdate(Integer... t){
show.setText("trytimes: "+t[0]);
}
@Override
    protected void onPostExecute(Integer result) {

pdloca.dismiss();
//show.setText("1101: "+currentData[0]+"1104: "+currentData[3]+" "+router[0].getTimes()+" "+task.getTryTimes());
    }
}

});Async