I have DialogFragment
and a Loader
.
Dialog prompts user to logout from Application.
When user chooses to logout I fire Loader
which clears the preferences and database and then I finish current Activity
.
After Loader
is finished I would like to start a new Activity
with login screen, but I encounter two problems:
getActivity()
method returns null
Activity
because I'm out of Activity
context
Do You have any solutions for this?
It doesn't sound like your situation warrants the use of a Loader
or the LoaderManager
at all.
Use an AsyncTask
to clear the preferences and database (perhaps showing a ProgressDialog
of some sorts if this operation is time-consuming).
When the task is complete, onPostExecute
is called. Write a callback method from the fragment to the activity which will first call startActivity(...)
and then call finish()
.