Вопрос

I'm trying to pass params into a AsyncTaskLoader. How do I do that?

Currently, I'm putting what I need to pass in in a separate static class. Anyway around this?

public class NewsAsyncTaskLoader extends AsyncTaskLoader<List<Content>> {

    private static final DbHelper dbHelper = DbHelperFactory.getDbHelper();

    public FeedAsyncTaskLoader(Context context) {
        super(context);
    }

    @Override
    public List<Content> loadInBackground() {
        List<Content> contents = DbHelper.getStream(FeedSections.getInstance().getCurrentSection());

        feed.setContents(contents);

        return feed;
    }
}
Это было полезно?

Решение

Pass additional parameters into your constructor:

public FeedAsyncTaskLoader(Context context, String moreInfo) {
    super(context);
    // Do something with moreInfo
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top