Search code examples
javaandroidandroid-asynctaskandroid-loadermanager

What is the 3rd argument type for getSupportLoaderManager(id, args, ??)


I've an AsyncTaskLoader method which restarts the current Loader,

It's for school purpose,

private void startAsyncTaskLoader() 
{
    getSupportLoaderManager().restartLoader(TASK_ID, null, this);
}

I can check the solution online on the school github but this is the good one, But in my android studio "this" (3rd argument) is incorrect type...

--> 
Wrong 3rd argument type. Found: 'com.openclassrooms.freezap.Controllers.MainActivity', required: 'android.support.v4.app.LoaderManager.LoaderCallbacks<java.lang.Object>'

I understand I placed a context argument (MainActivity) but I don't have an instance of LoaderManager.


Solution

  • What is the 3rd argument type for getSupportLoaderManager(id, args, ??)

    That method takes no arguments.

    If you really mean restartLoader(), the third parameter is android.support.v4.app.LoaderManager.LoaderCallbacks, as you can tell from your error message and from the documentation for restartLoader().