Note that the Loader Manager was deprecated while touching AsyncTask. To be honest, I don't know, but I will output it for the time being.
If you do the following, Android Studio will get angry.
MainActivity.java
private LoaderManager manager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
manager = getSupportLoaderManager();//← Not recommended
It will be struck through with ~~ getSupportLoaderManager () ~~.
That doesn't mean it doesn't work. It will move. But I was a little worried, so I read the official documentation.
There seem to be two ways.
1 is just that. I want an instance, so get it.
Gets a LoaderManager associated with the given owner, such as a FragmentActivity or Fragment.
... apparently ...
2, is that you start Loader.
If the loader doesn't already exist, one is created and (if the activity/fragment is currently started) starts the loader. Otherwise the last created loader is re-used.
If it doesn't exist, it will be made, and if it already exists, it will be reused. You can also see that LoaderManager is assigned to one of Activity and Fragment.
However, in the first place
Your activity must derive from FragmentActivity to use this.
So, it means that you should inherit FragmentActivity, but The question of what to do if you want to use it elsewhere remains unanswered.
Recommended Posts