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 returnsnull- I’m not able to run new
Activitybecause I’m out ofActivitycontext
Do You have any solutions for this?
It doesn’t sound like your situation warrants the use of a
Loaderor theLoaderManagerat all.Use an
AsyncTaskto clear the preferences and database (perhaps showing aProgressDialogof some sorts if this operation is time-consuming).When the task is complete,
onPostExecuteis called. Write a callback method from the fragment to the activity which will first callstartActivity(...)and then callfinish().