You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello mam, I followed your code, it is very interesting and understanding. In MainActivity.java,
loaderManager.restartLoader(BOOK_LOADER_ID, bundle, this);
In the above code, for callback : this
It is showing error
Required type:
LoaderCallbacks
Provided:
MainActivity
reason: no instance(s) of type variable(s) D exist so that MainActivity conforms to LoaderCallbacks
This one line code is stopping me from execution of entire app.
Please feel free to respond. This is my favourite app as a beginner. Thank you.
The text was updated successfully, but these errors were encountered:
Hi @Shivadumnawar , Thank you for being interested in my app. :)
I have not used this application since I finished it, and I am not following closely the Android development, however this is what I think:
The restartLoader's expects aLoaderCallbacks object as its third argument. The this object is a MainActivity class, but that class also implements LoaderManager.LoaderCallbacks<D> (precisely LoaderManager.LoaderCallbacks<List<Book>>, but the List<Book> does not matter now), so it should be correct, right? I quickly checked the documention, and this is what I found:
This interface was deprecated in API level 28.
Use the Support Library LoaderManager.LoaderCallbacks
It could be that you are using a newer version of the API and the restartLoader method actually expects a android.support.v4.app.LoaderManager.LoaderCallbacks<D> class. Do not be confused by the class name, if they are in a different namespace (e.g. android.app.LoaderManager vs android.support.v4.app.LoaderManager) they are different classes for the compiler. That can be the reason why you did not understand why the error message complains about the LoaderCallbacks while the this implements a LoaderCallbacks (it is, but another one).
It seems that the old LoaderCallbacks and the LoaderCallbacks have similar methods, so it can be enough that you just replace the namespace in line 23 (plus adjust the imports, etc.).
This is just a guess because, unfortunately, I do not have an Android development environment so I cannot test my theory. I hope it helps, and good luck learning! :)
Hello mam, I followed your code, it is very interesting and understanding. In MainActivity.java,
loaderManager.restartLoader(BOOK_LOADER_ID, bundle, this);
In the above code, for callback : this
It is showing error
Required type:
LoaderCallbacks
Provided:
MainActivity
reason: no instance(s) of type variable(s) D exist so that MainActivity conforms to LoaderCallbacks
This one line code is stopping me from execution of entire app.
Please feel free to respond. This is my favourite app as a beginner. Thank you.
The text was updated successfully, but these errors were encountered: