如何将params传递给Android AsnycTaskLoader

时间:2013-09-12 22:49:03

标签: android asynctaskloader

我正在尝试将params传递给AsyncTaskLoader。我该怎么做?

目前,我正在将我需要传递的内容放在一个单独的静态类中。不管怎么说?

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;
    }
}

1 个答案:

答案 0 :(得分:18)

将其他参数传递给构造函数:

public FeedAsyncTaskLoader(Context context, String moreInfo) {
    super(context);
    // Do something with moreInfo
}