我有一个静态类,需要调用另一个,第一个是静态的,并阻止我通过以下错误调用第二个:
No enclosing instance of type Studies is accessible. Must qualify the allocation with an enclosing instance of type Studies (e.g. x.new A() where x is
an instance of Studies).
AsyncTask类
class DownloadFileAsync extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {}
@Override
protected String doInBackground(String... aurl) {}
}
静态类
public static void startDownload(int id) {
ERROR LINE--> new DownloadFileAsync().execute("SOME URL");
}
谢谢!
最佳答案
您可以尝试new Studies().new DownloadFileAsync().execute("SOME URL");
但这不是完全面向对象的风格
关于android - 从静态类调用AsyncTask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11451768/