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

时间:2019-05-31 11:38:33

标签: java android android-asynctask android-loadermanager

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.

1 个答案:

答案 0 :(得分:1)

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().