我正在从AsyncTask进行远程http调用,我想显示一个微调进度对话框 我这样做了:
public class LongRunningTask extends AsyncTask<Object, Void, Void> {
Context ctx;
ProgressDialog prog;
public LongRunningTask(){}
public LongRunningTask(Context ctx) {
this.ctx = ctx;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
prog.dismiss();
}
@Override
protected void onPreExecute() {
super.onPreExecute();
prog = new ProgressDialog(ctx);
prog.setTitle("bla");
prog.setMessage("BLABLA");
prog.setIndeterminate(false);
prog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
prog.show();
}
....
}
从我的片段中我做到了:
new Thread(new Runnable() {
@Override
public void run() {
new LongRunningTask(getActivity()).execute();
}
}).run();
我的应用程序崩溃(没有任何堆栈跟踪......)
我该如何实现呢?