I have an Activity that has a fragment which is full screen RecyclerView
. The fragment implements LoaderManager.LoaderCallbacks<Cursor>
.
I have an IntentService that goes out and fetches data from an API, deletes any existing data in the local SQLite database, and then stores the new data all via a content provider.
The Loader then Loads whatever data was put into SQLite into the RecyclerView
.
My question is: Where would be the most efficient place to put my code to fire off the IntentService?
Just wondering if there are any conflicts that could arise if placed in an inappropriate place.
Currently, I have it as the last lines in OnCreate()
in the Activity:
// Fire off service to get data
Intent i = new Intent(this, MyService.class);
startService(i);
Other places I was considering putting it:
- In the
OnCreate()
in the fragment. - In the
OnActivityCreated()
in the fragment.