0

I recently tried to use a Loader to do background task in my app, but I've stumbled upon a problem as I implemented it. There is a conversion problem in the override of the onCreateLoader method (here is the code):

@Override
public Loader<ArrayList<Earthquake>> onCreateLoader(int i, Bundle bundle) {
    return new EarthquakeLoader(this);
}

The return line is all red in my IDE because it expects an android.content.Loader object but this returns an object of type MyPackageName.ActivityName.EarthquakeLoader

tom gautot
  • 378
  • 2
  • 10
  • Does `EarthquakeLoader` extend a `Loader` class; e.g., `AsyncTaskLoader` or `CursorLoader`? If so, check your `import` statements, as you're likely mixing platform and support `Loader`-related classes. – Mike M. Aug 02 '18 at 07:57
  • It extends AsyncTaskLoader and both android.support.v4.content.AsyncTaskLoader and android.content.Loader are imported – tom gautot Aug 02 '18 at 07:59
  • Yeah, you're mixing platform and support classes. Your `Loader`-related imports must all be either from `android.content`, or from `android.support.v4.content`. You can't mix them. – Mike M. Aug 02 '18 at 08:00
  • Ok thanks, I will fix this. – tom gautot Aug 02 '18 at 08:02

0 Answers0