我有这个代码片段:
public static class ExportDatabaseFileTask extends AsyncTask<String, Void, Boolean>
{
private final ProgressDialog dialog = new ProgressDialog(ctx);
protected void onPreExecute();
protected Boolean doInBackground(final String... args);
protected void onPostExecute(final Boolean success);
}
我将此线程作为
new ExportDatabaseFileTask().execute();
如您所见,我在新的progressdialog调用中使用ctx作为上下文变量,如何将上下文传递给call方法?
对此:
new ExportDatabaseFileTask().execute();*
最佳答案
我找到了方法,我必须创建自己的构造函数,然后丢失静态的东西
public ExportDatabaseFileTask(Context ctx) {
super();
this.ctx=ctx;
dialog= new ProgressDialog(ctx);
}