문제

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