I have a public class FriendMaps extends MapActivity
that gets called from a menu item when selected, and at the end of that I have private abstract class DownloadFilesTask extends AsyncTask<Void, Void, Void>
in there I do some server calls and put data into local arrays etc.
But in my public void onCreate(Bundle savedInstanceState)
of the FriendMaps activity I call new DownloadFilesTask().execute();
and get the following error:
Error: Cannot instantiate the type FriendMaps.DownloadFilesTask
From the documentation:
AsyncTask must be subclassed to be used.
That would be accomplished DownloadFilesTask extends AsyncTask
there.
The task instance must be created on the UI thread
Maybe this is where I am confused? To my understanding the UI thread is the current activity being displayed - if so then the onCreate of the FriendMaps activity is the correct place to execute();
If full code spinets are required for further help, please comment and I'll add where needed.
您无法实例化它,因为您将DownloadFilesTask
声明为一个抽象类,根据定义,该抽象类无法实例化
You might want to make your declaration like this
private class DownloadFilesTask extends AsyncTask<Void, Void, Void>
You probably didn't mean it to be an abstract class, and as @maid450 said, you can't instantiate an abstract class.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.